I have created a Windows application. When I execute my executable manually it is working fine, but when I run my exe using a Windows service it showing provide fail error. I am using Entity Framework. Is there any problem with Entity Framework?
Here is my code:
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;
}
I checked my web service and printed the exception message to my notepad, and found this error:
The underlying provider failed on Open.
But I only get this error when running as a Windows service. If I run my exe manually it works fine. Is there any need to add references in Windows services?