Using The Debugger To Break When An Exception Is Thrown In Your Application

By default, if you have an exception handler defined, the debugger in Visual Studio will not break (i.e. stop) at the point where an exception is thrown.

You can, however, configure Visual Studio to break at the point when the exception is thrown. To enable breaking when an exception is thrown, do the following,

  • From the Debug menu, select Exceptions…

    914-001
  • Find the specific type of exception for which you want the debugger to break and click on the Thrown column. You can select an entire class of exceptions, or a specific exception type. In the example below, we select all Common Language Runtime Exceptions.
    914-002
  • Click the OK button

Now, when you run in debug mode, the debugger will display a dialog at the point where an exception is thrown and give you a chance to break (stop).

914-003

If you do break, you can then examine the exception object.

914-004

Ebook Download
View all
Learn
View all