views:

183

answers:

3

I have a dotnet windows service that's currently hung, but running. Is there anyway to attach a debugger to it, despite the lack of symbols; and that it's already running?

+2  A: 

From MS dev IDE Debug -> Processes -> Attach (After you choose a process.) You might have to click the "show system processes" box. There may be no useful information though...

Tim
Don't you get a no debug symbols can be found for this process?
Orion Adrian
And yes you can list a service that way as long as it's in its own process.
Orion Adrian
If there are no symbols, yes. But if you want to step through the assembler code you can.
Tim
Is this a service you have source code access to?
Tim
Yes, I have the source code.
Orion Adrian
This would be a good idea for a compiled exe where you could get a stack trace and link the it to somewhere in the original code, but I can't see what usable info he could get from a "jit" compiled .net app (just guessing here, I never tried it so correct me if I'm wrong)
Hrvoje Prgeša
Shog9's answer looks like a good one...
Tim
+4  A: 

Ignore the "no symbols" warning. Once you have a native debugger attached (i prefer WinDbg for stuff like this), then load up the SoS tool pack:

.loadby sos mscorwks

Now you can get a managed callstack using the !clrstack command, and hope that gives you enough information to figure out the hang. Here's a handy cheat-sheet with a few others if that doesn't do it for you.

Won't help you this time, but... get in the habit of turning on symbol file generation for debug and release-mode builds. There's no reason not to, and it'll make your life a bit easier in situations like this.

Shog9
I just want to second that you should be doing symbol file generation for debug and release builds.
LanceSc
+2  A: 

Here is sample code, links to tools, and presentations on how to debug a hung .NET process.

You probably also want to watch this video presentation, which features the same tools and samples. Despite the Swedish text on the web page, the video is in English.

Craig Stuntz