How to debug windows service

If you are wondering how to debug windows service application, this article is for you.  Since windows service application is running within the context of Services Control Manager rather than from Visual Studio, It’s not a straightforward to debug windows service like other .net application.

Follow the below steps to debug windows service application.

  • Install your window service application

To install windows service, open visual studio command prompt and run following command to install

Installutil.exe –i servicefullpath.exe

  • Start your service from Service Control Manager
  • Go to visual studio and launch process window by clicking Debug –> Attach to Process
  • Check option “Show processes from all users” if it is unchecked
  • Click the process of your windows service (you will see the name of the exe of that windows service in list for example: TestWinService.exe) and attach that process
  • Set any breakpoints in your code and you all set to debug

Please leave comments/questions here.

Posted in Microsoft Technology Tagged with: