Kevin McPhail Kevin McPhail - 3 months ago 17
C# Question

Visual studio Attaching debugger to windows service -- attach greyed out

I am trying to attach to a windows service using the Visual Studio 2010 --> Debug --> attach to process command. When i scroll through the list of processes my windows service is greyed out and the attcah button is also greyed out. I have tried changing the service account to loacal service, my account, etc but it remains greyed out. Anyone have any suggestions or anyway to troubleshoot this?

Answer

I usually have the same issue and I take care of it by adding a bool to my config that triggers a debug launch. You can launch a VS debugger instance that attaches to your win service process by calling this:

System.Diagnostics.Debugger.Launch();

What's nice is you can call it wherever you wish in your code.