Hey guys!

Does anyone out there know of a way to debug a windowsservice?

Fanx and happy coding! :)

You can attach to the process once it has started (Debug Menu - Attach to Process), but for some service related tasks blocking the process with a break point introduces timing delays that can cause the service to operate incorrectly or fail completely. The best way is to use a logging tool.

One logging tool I have used in the past is Log4Net.

Another (and simpler) way is to log to the events log using the ServiceBase.EventLog.
ServiceBase.EventLog Property
EventLog Class

In either case you could (should) use a registry entry or application setting to set the level of logging to perform.
E.g. Verbose to log everything or Basic to only log simple events.

If you use the EventLog you can view the log by

  1. Right click on My Computer
  2. Select Manage
  3. Open Event Viewer
  4. Open Application log

Hey nick fanx for the tips!

I am already using the Event log to display messages as you suggested. You see I am using a Windows Service to expose a Web Serrvice call, so (and i hope i am explain this correcty) I have a front end (a consuming application)that for example that has some button click event when I click it and debug the application ands then try and step in to the debugging process - the problem is the when I hit F11 and try step into the whole process I get an error that says: "...debugging has not been enabled on server". I have google a lot on this and some say that in the app config file of the service I should include the "debugging = true" - well that hasn't work.

I cant find a lot of posting where folks have done what I am trying to achieve but then again a challenge is always fun!

So any advice and tips on this whould be real great!

Fanx nick and happy coding ! :)

This article has been dead for over six months. Start a new discussion instead.