Monday, January 4, 2010

How to debug Windows service

In web apps we generally press F5 or attach the process for debugging but what to do when it comes to Windows services ???

You"ll come across docs which tell you to do loads of steps for that, but I prefer the most easy way ;)

The process of attaching debugger can be done in just ONE simple line. Use

System.Diagnostics.Debugger.Launch()

The Launch() is a static method of Debugger class. It initializes the debugger.

Now where to put this line ?? Well I prefer in the OnStart() of the Windows service which acts as a starting point of the service.

So you are all set with debugging the Windows service. Happy Debugging :)

No comments: