Debugging Windows Service in Visual Studio

After some searching and testing how to debug a windows service, I found that for me the following solution is working very well.

First register your service as a service on your machine. This can be done with a few simple steps. How to do this is described in this article:

Next add a line / lines Debugger.Break(); in your code where you want the debugger to start. Now compile in debug mode clicking in Visual Studio menu: Build, Build Solution while the Configuration Manager is set to Debug.

After the application compiled successfully we can stop and start the service to ensure these modifications are run:

I used the tips from and

Right click the Visual Studio application and select more…, Run as administrator

Click Debug, Attach to Process in the Visual Studio menu.

This will open a dialog where you need to select the right process to debug. Check the Show processes from all users checkbox. Find your Service process and click Attach.