I have a windows service that is, intermittently, throwing an exception that sometimes kills its SQLConnection, and other times kills the service completely. It is running live on a customer's site.
I have planned to use Windbg + SOS on it to get a crash dump, so that I can debug this at my own leisure.
On my first attempt, however, the debugger halted the service when it hit a first chance exception that was being caught and handled in the code (as I used the sxe clr
command).
The help file appears to suggest I use sxd clr
, instead of sxe clr
, to capture second change exceptions instead of first chance exceptions.
In my testing, however, a generated, caught and handled exception is being treated exactly the same as a thrown exception (but not caught) by the sxd clr
command, namely it's noted and ignored.
Is this behaviour, of not stopping on a thrown exception, possibly as I threw the exception explicitly in my code, or are will all clr exceptions fail to halt the debugger with the sxd
command? Should I be using a different command?
Secondly, As Windbg doesn't specifically recognise clr errors, is it possible to tell it to stop only on a specific, unhandled, exception (i.e. InvalidOperationException)
It is probably easier just to use adplus for creating the dump file. This article shows how to create minidumps for specific .NET exceptions using adplus.
If you're working with WinDbg, you need the sos extension and a command like
sxe -c "!soe System.InvalidOperationException 1; .if (@$t1==1){!pe} .else{g}" clr