0

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?

Icaro
  • 14,585
  • 6
  • 60
  • 75

1 Answers1

1

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.

Sebastian
  • 3,764
  • 21
  • 28
  • Thank @lowleveldesign I had a look in the links and they are very helpful, unfortunately I still cannot figure out why the service start and stop, I am guessing is some thing to do with the windows processes as it happens before my logging even start what is the first thing I do – Icaro Jun 26 '15 at 00:46
  • @Icaro have you tried process monitor? There is a Tools->Process Tree dialog there. Find your process, then right click and choose to filter events by this process. Do you see any suspicious results, such as ACCESS DENIED? You may share the collected trace if you'd like some help with it. – Sebastian Jun 26 '15 at 11:44