9
votes

I'm getting exceptions thrown from somewhere, but all I get from the compiler is "A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll". This is fairly useless to me, as that's not my code (pretty sure it's default library). I'd like to see a stack-trace or something so I know where in my code things went wrong. It's a fairly large codebase (much of which is not mine), and there's a lot of multi-threading and other stuff going on, so it's nearly impossible to try and step through the code without some idea of where to start looking. Is there some setting somewhere to make ALL exceptions trigger a break so I can see the call-stack when they occur, rather than just having them silently fail with a completely useless error message in the output?

1
You can see the stack when the exception is thrown on debug mode. - SimpleVar
If you're in visual studio, try Debug Menu > Exceptions and check all exceptions you want to break on. - gcochard
@Darrel You really should accept answers to your questions, even if you answer your own. People will be more willing to help you that way. - Bob Horn
I would if the system would let me - I have to wait 24 hours before I'm allowed to accept my own answers because I'm a newbie. There were a few that I don't think were adequately answered, but nobody seemed to care about them (Yay tumbleweed badge!). As for this one, I do sleep sometimes... - Darrel Hoffman

1 Answers

17
votes

You have a couple of options. First, like Greg said, you can cause VS to break when any exception occurs:

enter image description here

Make sure these are checked, then click OK:

enter image description here

That will cause Visual Studio to break wherever the exception occurs.

Another approach is to catch the exception and either write just the stack trace, or write the exception (using ToString()) to the output window:

enter image description here

Then check your output window:

enter image description here