
152
|
Chapter 5, Debugging
#38 Customize Visual Studio’s Reaction to Exceptions
HACK
HACK
#38
Customize Visual Studio’s Reaction to
Exceptions Hack #38
Exceptions are a sometimes-frustrating part of debugging and developing.
You can configure Visual Studio to deal differently with certain exceptions.
When debugging a program in Visual Studio, a number of situations may
cause the debugger to enter break mode. When the debugger enters break
mode, program execution is suspended, allowing you—the developer—the
opportunity to examine and change the program variables. With Visual Stu-
dio 2005, you can even alter the program’s underlying source code when in
break mode and have the program continue with the edited source.
A common way that break mode is entered is through breakpoints
[Hack #36].
Another way that break mode is regularly entered is when an exception is
raised that is not handled by your application. Any exception that bubbles
up out of your user code will cause the Visual Studio debugger to display
information about the exception. While you will likely always want to be
notified of an unhandled exception when debugging, you may want to break
when an exception is thrown, regardless of whether or not it’s handled.
Visual Studio can be easily customized to break immediately when a particu-
lar type of exception is thrown.
Use the Exceptions Dialog Box
To customize Visual Studio’s behavior when encountering ...