我已经创建了一个Windows应用程序。当我手动执行我的可执行文件时它工作正常,但是当我使用Windows服务运行我的exe时,它显示提供失败错误。我正在使用实体框架。实体框架有任何问题吗?Exe文件没有从我的Windows服务与数据库连接运行?
这里是我的代码:
private void Threadfun()
{
try
{
System.Diagnostics.Process.Start(@"D:\V-Tec\bin\Debug\VibrantIndexerForm.exe");
if (System.IO.File.Exists(@"D:\VibrantIndexerSetup\MarcExport1.txt"))
{
}
else
{
System.IO.File.Create(@"D:\VibrantIndexerSetup\MarcExport1.txt").Dispose();
}
System.IO.File.WriteAllText(@"D:\VibrantIndexerSetup\MarcExport1.txt", System.DateTime.Now.ToString());
System.Threading.Thread.Sleep(100);
}
catch (Exception ex)
{
}
}
private void time_Elapsed(object sender, ElapsedEventArgs e)
{
m_thread = new System.Threading.Thread(new System.Threading.ThreadStart(Threadfun));
if (m_thread.IsAlive)
{
}
else
{
m_thread.Start();
}
}
protected override void OnStart(string[] args)
{
if (time.Enabled == false)
{
time.Elapsed += new ElapsedEventHandler(time_Elapsed);
time.Interval = 2000;
time.Enabled = true;
}
}
protected override void OnStop()
{
time.Enabled = false;
}
我检查我的web服务和打印异常消息给我的记事本,发现了这个错误:
The underlying provider failed on Open.
但运行时,我只得到这个错误作为Windows服务。如果我手动运行我的exe,它工作正常。有没有必要在Windows服务中添加引用?
尝试看到窗口logs.windows服务在这里写了例外 – Frank59
是的,我发现我的Windows日志中的错误描述,但我怎么能解决这个问题。 –
你可以在你的文章中添加错误描述吗? – Frank59