The compiled executable file that a service application project creates must be installed on the server before the project can function in a meaningful way. You cannot debug or run a service application by pressing F5 or F11; you cannot immediately run a service or step into its code. Instead, you must install and start your service, and then attach a debugger to the service's process.
Here we are going to see how to debug our own windows services.
Steps for debugging windows services:
- Install your service. In my case it is the service which I created and installed as mentioned in my previous article i.e. Birthday Wish Scheduler in C#.
- Start the service.
- Open your project in Visual Studio.NET.
- Then choose processes from the Debug menu. The following windows will appear.
- Click on "Show system processes".
- 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.
- Clicking Attach will show "Attach to Process" dialog box.
- Choosing the appropriate option will bring the application in debug mode.
- Insert breakpoints to debug the service.
- From the service control manager, use different options like start, stop etc. to debug it.
Until next time.....Happy .NETing!