How To debug a Window Service:

  1. Install your service.
  2. Start your service, either from Services Control Manager or Server Explorer.
  3. In Visual Studio, choose Attach to Processes from the Debug menu.
  4. Click on Show processes from all user
  5. From the available processes, look for the process created by your service. The process name will be same as the executable file of the service.
  6. Click on Attach.
  7. Choosing the appropriate option will bring the application in debug mode.
  8. Insert breakpoints to debug the service.
  9. From the service control manager, use different options like start, stop etc. to debug it.


  • You can’t debug the OnStart() and Main() methods because you can only attach a debugger to a service after it has started running, which by then, the OnStart() method has already completed its execution and returned the control to the operating system.
  • You must attach the debugger each time the project is restarted.