Posted by: R Manimaran | October 2, 2008

Debug a Windows Service in Visual Studio 2005

Debug a Windows Service application in Visual studio 2005
For normal application we can set the breakpoint in Visual studio and start debugging by pressing F10 or F11. But for the Windows services application we can’t directly debug the application. Following steps will help to debug the windows service application.

1. Create the setup project for the Windows Service application.
2. If the Solution contain more than one Project, select the Windows Service project as the Start up project by right-click the project and select Set as Startup project
3. In the Solution configuration select Debug mode. In the release mode we can’t debug the application.
4. Install the Windows service setup in the system
5. Go to the services and start your windows services. Once it successfully started proceed to next step.
6. Set Breakpoint on your application( press F9 for breakpoint)
7. Go to Tools–>Options menu in the VS 2005
8. Select Debugging –>Symbols

9. In the Symbol file(.pdb) locations add the path of the pdb file path.(should include the pdb file name also)
i.e \Debug\

10. The Pdb file is located in the application Debug directory.
11. In the Cache symbols servers to this directory browse the path where the Pdb file is located.(no pdb file name required here. Only path up to Debug folder)
12. Click ok to set your setting. After finishing this again to this window and double check that your options are still available.
13. Select Debug–>Attach to Process option as shown in fig

14. Select your running windows service in the Available processes

15. Click Attach button to attach the Windows service to your application.
16. Now you can see the application is starts running.
17. Please wait until the flow reaches your breakpoint.
18. Once it reaches your breakpoint then you can use your normal F10 or F11 keys to debug the application.

happy Coding!!!



  1. Could you please advice why is the service grayed out (in the attached to process screen) after i call InstallUtil.exe serviceCode.exe


  2. I could not understand what you are looking for..? Can you explain it more?

  3. Great article !! The method of attaching has to be quick though .. isn’t it? …. I found this interesting too …

  4. Great article !! The method of attaching has to be quick though .. isn’t it? …. I found this interesting too …

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: