Paul Laudeman's Blog

Helping You to Make "Smart Clients" Smarter

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

.NET Notables

My Community Support

My User Groups

Blog-'o-Rama

More .NET

The "Other" Side

Subscriptions

News

Catch-me-if-you-can

  • MSN Messenger: plaudeman at hotmail dot com
Get Firefox!

Article Categories



Debugging Tip: Break on unhandled (and otherwise ignored) exceptions

While writing up some code, I noticed that an exception was being generated but not caught by some code that I had written for a Winforms application. As it turns out, the exception details were dumped to the output window in Visual Studio .NET but the level of detail seemed to point to an error in a third party control. Puzzled, and not sure where to really start, I remembered that you could instruct VS.NET to break into your code at the point where an exception was thrown, even if you chose not to handle it and the debugger would otherwise not break on it.

To instruct VS.NET to break on unhandled exceptions, or at the point the exception is thrown, select Debug / Exceptions:

This will bring up the Exceptions window where you can specify which specific exceptions you want to break on, or to break on any type of exception. Since I knew that the type of exception being thrown was of System.ArgumentException, I decided instruct VS.NET to break when that type of exception is thrown:

After I had made this change and rerun my code, I easily spotted the problem and was able to correct it. If I did not know how to do this, I could have spent a lot of extra time stepping through the code or putting in extra Trace statements to find the point where the exception was being generated.

Configuring the IDE to break on exceptions can be useful to jump to the line of code immediately, rather than having to manually set a breakpoint in your code, and can signficantly reduce the amount of time you spend debugging.

posted on Wednesday, December 24, 2003 6:39 PM by plaudeman





Powered by Dot Net Junkies, by Telligent Systems