Debugging Windows Services while starting

193 views Asked by At

How can I debug an windows service when it is starting?

I have an windows service that is falling to start and I add all the logs that I could but something is happening behind the scenes (between the installed service and Windows) that I cannot see (as far as my knowledge go).

I am not looking for code debugging here but windows message between the service and Windows, but I can't find any in event log, maybe I need to turn it on?

I am thinking that something between the lines of windows think my service is a virus, or windows is not been able to connect to my service by name, something like that.

Does anyone know how I can see this kind of information on Event Viewer or similar?

1

There are 1 answers

2
Sebastian On

Debugging of Windows services is quite challenging as they are running in session 0 with no desktop and user interaction possible.

One way to debug your service is to setup a remote debugging session with windbg as described here.

Another way is to use my winsvcdiag tool which should make the process simpler and possible to debug from VS: https://lowleveldesign.wordpress.com/2015/06/22/how-to-debug-windows-services-written-in-net-part-ii/

And I'm not sure what type of event logs you want to see. When a windows service is failing there is usually a brief message in the System log. You may always look if process monitor is reporting any errors for your service.