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?
views:
102answers:
3
+1
A:
Make sure you run Visual Studio as an Administrator. It will require administrator rights to attach to a running Service.
Reed Copsey
2010-09-09 20:41:58
Tried this but no luck. I can attach to other services listed in the process list, just not the one i need to. :)
Kevin McPhail
2010-09-10 12:57:50
+1
A:
You may not have permissions to attach to the service. Do you have admin privileges on the desktop? Many corporations do not allow this by default, supposedly to assist in securing their environment.
Steve Townsend
2010-09-09 20:42:24
Yea, i have admin privs and i tried to right click and run as administrator in vs to see if that helped. No luck.
Kevin McPhail
2010-09-10 12:58:32
Are you in a position to try the Alternate Debugging Strategies described here: http://msdn.microsoft.com/en-us/library/7a50syb3(VS.80).aspx ?
Steve Townsend
2010-09-10 13:17:11
Steve, thanks for the link. I had actually looked at that page but did not see the alternate strategies at the bottom. I have used a console to test services before and that is a pretty decentalternative.
Kevin McPhail
2010-09-15 13:04:22
Welcome. I'd be interested to know how this was or is resolved for you.
Steve Townsend
2010-09-15 13:15:23
+1
A:
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.
jlafay
2010-09-09 20:51:13
I like this. A nice simple way to launch a debugger from a service. Next question is there a way to remotely attach using this method if the service is installed on another machine?
Kevin McPhail
2010-09-13 14:57:45
Don't have an immediate answer but that would be beneficial to me as well. I'll see if there's an easy way to achieve it and if so I'll edit my answer to include that solution as well.
jlafay
2010-09-13 17:07:33