Tuesday, May 19, 2009

How do I configure the Visual Studio debugger to break when an exception is thrown?


In Visual Studio go to the Debug | Exceptions | Common Language Runtime Exceptions | System and select System.NullReferenceException.

In the When the exception is thrown group box, select Break into the debugger.

Run your scenario. When the exception is thrown, the debugger will stop and notify you with a dialog that says something like:

An exception of type "System.NullReferenceException" has been thrown.

[Break] [Continue]

Select [Break]. This will put you on the line of code that's causing the exception.

No comments: