Visual-studio – Visual Studio: How to break on handled exceptions

debuggingexceptionvisual studio

I would like Visual Studio to break when a handled exception happens (i.e. I don't just want to see a "First chance" message, I want to debug the actual exception).

e.g. I want the debugger to break at the exception:

try
{
   System.IO.File.Delete(someFilename);
}
catch (Exception)
{
   //we really don't care at runtime if the file couldn't be deleted
}

I came across these notes for Visual Studio.NET:

1) In VS.NET go to the Debug Menu >>
"Exceptions…" >> "Common Language
Runtime Exceptions" >> "System" and
select "System.NullReferenceException"

2) In the bottom of that dialog there
is a "When the exception is thrown:"
group box, select "Break into the
debugger"

3) 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]"

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

But they do not apply to Visual Studio 2005 (there is no Exceptions option on the Debug menu).

Does anyone know where the find this options dialog in Visual Studio that the "When the exception is thrown" group box, with the option to "Break into the debugger"?

Update: The problem was that my Debug menu didn't have an Exceptions item. I customized the menu to manually add it.

Best Answer

With a solution open, go to the Debug - Exceptions (Ctrl+D,E) menu option. From there you can choose to break on Thrown or User-unhandled exceptions.

EDIT: My instance is set up with the C# "profile" perhaps it isn't there for other profiles?