Wednesday, October 30, 2013

Debugging a Windows Services

We cannot run Windows Services, directly like running a Windows or Web application; we need to install the Windows Service in the service console for it to operate. Hence we cannot debug windows services directly, use the following procedure to debug a windows service. 
1.Build the Windows Service project
2.Install and Start the Windows service.
3.Open the Windows Service Project in Visual studio
4.Select Debug -> Attach to Process
5.From the list of processes, select the process of the installed Windows Service. 
6.Click Attach, this will attach the process to the Project.
7.Add breakpoints to the code.
8.Since the timer triggers only after the defined interval (2 mins in my case), we can start the service, attach the process and add breakpoints before the time elapses. Once the time elapses, the method associated with the timer (TriggerErrorNotifications in my case) will get fired, and execution will break when it finds a break point.  

Search Flipkart Products:

No comments: