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)
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.