Starting a windows service fails with error 1053

后端 未结 10 1384
逝去的感伤
逝去的感伤 2020-12-10 13:41

I have a windows service that is failing to start, giving an error \"Error 1053: The service did not respond to the start or control request in a timely fashion\".

10条回答
  •  轮回少年
    2020-12-10 14:30

    I ran through every post on this particular subject and none of the responses solved the problem, so I'm adding this response in case this helps someone else. Admittedly this only applies to a new service, not this specific case.

    I was writing a File listening service. As a console app, it worked perfectly. When I ran it as a service, I got the same error as above. What I didn't know (and many of the MSDN articles about services conveniently leave out) is that you need to have your class executed from within ServiceBase.Run( YourClassName());. Otherwise, your app executes and immediately terminates and because it terminated, you get the error above even if no error or exception occurred. Here is a link to an article about this. It actually discusses setting up your app for dual use - Console app and service: Create a combo command line / Windows service app

提交回复
热议问题