Window service getting stopped continuously

Asked By 10 points N/A Posted on -
qa-featured

Hi! All,

I am facing a very unique issue, where a Windows service is getting stopped immediately after starting again and again.
On looking into application event log, I have found several messages like ".NET SqlClient Data Provider failed to initialize properly (0xc0000142)."

However the same service is running fine on its backup server, which suggests that the database server on which it depends is free from any issue. Has anyone faced the similar issue and can provide me some possible causes of this behavior?

Thanks a lot.
 Paul
SHARE
Answered By 0 points N/A #130895

Window service getting stopped continuously

qa-featured

Hi! Friends,

Windows service getting stopped continuously is a complex problem. If you are not running any threads on start method to make your work, so an exception can appear to your on start method. By exception thrown windows event log will appear and event log is good for amu case start.

If you want to look on start method you will find it like this on start method,

 Thread _thread; 

protected override void OnStart(string[] args)

   ( // Comment  to debug

    // Debugger.Break()

    //  initial setup and initialization

    Setup();

    // leave a thread to do work

    _thread = new Thread(new MyClass().MyMethod)

    _thread.Start();

    // close this method to indicate the service has started)

Login/Register to Answer

Related Questions