Home

Aug 25, 2008

How to debug window service ?

Hi All,

Every now and then we work with window service for integration of our CRM project. As far as debugging is concern, windows service is pain. Let see simple method to debug a windows service.

1. This is the three line of code you are going to use to debug the service.

#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif
2. Go to Program.cs
3. Put this code inside static void Main() method.
4. Build the windows service in debug mode and install it using installuti.exe.
5. Open windows service project while starting windows service.
6. On start of windows service it would ask you to debug the service. Select the windows service project. Now would be in world of debugging windows service.

Thus you can start the debugging of windows service.

Thanks,

Amol G

1 comment:

shweta singh said...

This really helped in my current project as I am only working on windows service. I do have a workaround but it takes much more time than using this simple 3 line code...Thanks Amol.