简体   繁体   中英

Winsows Service failed to start

I have a problem with starting my Windows Service. It's configured to start automatically and it usually does start. On sometimes it doesn't, especially on Windows 8.

The windows log contains following error:

The XYZ service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion. A timeout was reached (30000 milliseconds) while waiting for the XYZ service to connect.

This is a .NET 2.0 service.

The standard cause of the problem is OnStart method that perform long synchronous operation. This is not an issue this time. In fact, I've placed a file logger in the beginning of the OnStart method and it looks like it's not invoked at all.

It turned out that the problem was cause by two issues:

  • the executable file (exe) was signed digitally;
  • there were Internet connection problems and accruing IP took a long time;

The two combined caused the service start process to timeout due to too long certificate validation.

I had to use this on native c win32 services, and searched if .NET has something similar. Sorry if i'm wrong.

In your OnStart, use the RequestAdditionalTime method to inform the service control manager that the operation will require more time to complete. Documentation here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM