How to debug a Windows Service in Visual Stdio once it is installed

To debug a Windows Service once it has been installed follow
the steps below

1)
Copy the pdb files in the same folder where rest
of the dlls are for Windows Service

2)
Go to visual studio and Tools>Attach to
Process

3)
Look for something with the name of your Windows
Service (Make sure windows service is running)

4)
If you want to run Windows Service before you
attach to a process it is already passed the step you want to debug then best
way is to put it to sleep for two minutes or so….Something like below should do
the job

System.Threading.Thread.Sleep(20000);

Now run the service and attach it to process and you should be able to step into code

Comments are closed.