Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure the visual studio debugger for try-catch statements

VS 2005

For example,

My employees gave me a project with about X try-catch statements.

X > 100 .. 300

I need to test a project. Is there a way to mark each (every) beginning of catch as a breakpoint ? I don't want to do it manually. Maybe there is some settings that fit to me ?

like image 578
Alexander Stalt Avatar asked Apr 07 '10 06:04

Alexander Stalt


1 Answers

Go to Debug > Exceptions (Visual Studio 2013 and earlier) or Debug > Windows > Exception Settings (Visual Studio 2015 and later).

In this dialog you can enable first chance debugging of exceptions - when an exception is thrown, the debugger will automatically break at the throwing code before the "catch" code is executed, allowing you to debug it.

What you want to do is ask it to break when CLR exceptions are thrown, not only when they're unhandled (image from Visual Studio 2013 - 2015 is similar but now is in a view rather than a dialog):

alt text

(Note: This won't get the debugger to break whenever you execute a try block, only if the exception is actually thrown)

like image 100
Jason Williams Avatar answered Sep 28 '22 12:09

Jason Williams