MStodd
MStodd

Reputation: 4746

Can I get a stacktrace from a CLR exception without attaching the VS debugger?

I have a website running on a remote server, and want to get some information from an exception that is occurring. I can't install VS or use remote debugging, and have been trying to use various versions of WinDbg with little success. In my local tests, I can get WinDbg to break on a C++ exception, or a CLR exception that I threw, but can't get much more information than 'something was thrown'.

Is WinDbg the way to go, or is there another way, or am I screwed for not having adequate logging?

Upvotes: 10

Views: 9933

Answers (1)

seva titov
seva titov

Reputation: 11920

Attach WinDbg to the process, then enter these commands:

.symfix
sxe clr
sxd av
.loadby sos clr
g

The execution will continue (after go command) and will break whenever CLR exception is thrown (or any other unhandled exception). Whenever it breaks on CLR exception you see:

(xxxx.xxxx): CLR exception - code e0434352 (first chance)

Then you can use SOS commands like !pe to print out exception type, !ClrStack to dump stack, !dso to dump managed objects in the stack, etc.

EDIT: I had typos in sxe and sxd commands. Thanks to @MStodd for noticing that.

Upvotes: 20

Related Questions