Debuging windows service using .NET or Visual Studio 2008

I was having problems debugging a windows service, so I goggled it to find answers. below is my solution in detail.

Run Visual Studio As Administrator

Make Sure Your Project is set to "Debug Mode" not release mode.

Within the onStart even of Service Put this Code:
        While (True)
        End While
And Set the Breakpoint on System.Threading.Thread.Sleep(500)

Install the Service using InstallUtil
cd "C:\Windows\Microsoft.NET\Framework\v2.0.50727"
installutil "C:\Users\ja\Desktop\Projects\Feeds\FeedsService\bin\Release\myService.exe" 

Start The Service from Windows Service Utility.

Go back to Visual Studio 2008 Tools > Attach to Process (Make sure all check boxes are checked), choose the name of your service and hit Attach Button.

Now you should be in debug mode within your Service, Drag the Breakpoint out of the While Loop and deBug your Code.

Posted by:

No comments posted.

Name :  

Email :  

Comment Below