If you’re trying to get a stack dump while the process is already running (a la jstack), there are two methods as described here:
Using Managed Stack Explorer
There is a little-known but effective tool called the Managed Stack Explorer. Although it features a basic GUI, it can effectively be a .NET equivalent of jstack if you add to the path; then it’s just a question of typing:
mse /s /p <pid>
Using windbg
- Download and install the appropriate Debugging Tools for Windows version for your architecture (x86/x64/Itanium)
- If you need information about Windows function calls (e.g. you want to trace into kernel calls), download and install the appropriate symbols. This isn’t strictly necessary if you just want a thread dump of your own code.
- If you need line numbers or any other detailed information, make sure to place your assemblies’ PDB files where the debugger can find them (normally you just put them next to your actual assemblies).
- Start->Programs->Debugging Tools for Windows [x64]->windbg
- Attach the debugger to your running process using the menu
- Load the SOS extension with “.loadby sos mscorwks” for .NET 2.0 (“.load sos” for .NET 1.0/1.1)
- Take a thread dump using “!eestack”
- Detach using “.detach”
I just found it necessary to take a production thread dump and this worked for me. Hope it helps 🙂