Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable Visual Studio 2010 to break when a first chance exception happens?

I was reading Stack Overflow question How can I set Visual Studio to show a stack trace for first chance exceptions? regarding debugging first chance exceptions on Visual Studio 2010, and I am not able to find this option.

How can I enable Visual Studio 2010 to break exactly when a first chance exception happens?

Enter image description here

like image 342
Junior Mayhé Avatar asked Nov 21 '11 20:11

Junior Mayhé


People also ask

How do I enable Break on exception in Visual Studio?

Tell the debugger to break when an exception is thrown In the Exception Settings window (Debug > Windows > Exception Settings), expand the node for a category of exceptions, such as Common Language Runtime Exceptions. Then select the check box for a specific exception within that category, such as System.

How do I turn off exceptions in Visual Studio?

In the Debug > Exceptions dialog, click Add, select Common Language Runtime exceptions, and enter the full name (not the assembly-qualified name) of the exception. Then uncheck the Thrown checkbox for this exception.

How do I stop exception breakpoint?

Remove breakpoints For non-exception breakpoints: click the breakpoint in the gutter. For all breakpoints: from the main menu, select Run | View Breakpoints Ctrl+Shift+F8 , select the breakpoint, and click Remove Delete .


2 Answers

You may want to check the Debug menu in Visual Studio 2010. In there you will find the Exception submenu, in where you can select which type of exception you want Visual Studio to stop.

Setting the debugger to break when an exception is thrown

The debugger can break execution at the point where an exception is thrown, giving you a chance to examine the exception before a handler is invoked.

In the Exception Settings window, expand the node for a category of exceptions (for example, Common Language Runtime Exceptions, meaning .NET exceptions), and select the check box for a specific exception within that category (for example System.AccessViolationException). You can also select an entire category of exceptions.

enter image description here

If you check a given exception, debugger execution will break wherever the exception is thrown, regardless of whether it is handled or unhandled. At this point the exception is called a first chance exception.

See How to: Break When an Exception is Thrown for more info.

like image 182
fduff Avatar answered Sep 24 '22 04:09

fduff


In Visual Studio to enable 1st chance exceptions we can open the exceptions window and check the throw CLR Exception chekbox.

On the debug menu select exceptions. (Ctrl + Alt + E)

There is a Common Language Runtime Exception Thown checkbox that we can check; then click OK.

The screen show below is from VS2012:

enter image description here

Hope this helps

like image 26
Catto Avatar answered Sep 26 '22 04:09

Catto