Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell the debugger to ignore breaking on thrown exceptions?

Tags:

I have a TextBox in which I validate the input with a third party library. However, this library throws custom exceptions when the syntax is incorrect. This is not a real big deal, except for when you are debugging.

When debugging, since the text in the TextBox will always be initially wrong (I am still typing it), the debugger will stop after each letter until it is correct, which is really annoying as I validate with each letter.

How can I tell the debugger to not break at these custom exceptions?

P.S. I have already tried to filter the Debug -> Exceptions (added it in Common Language Runtime Exceptions), but this did not work for me. The debugger still stops at the line where the library is called.

P.P.S. Using Visual Studio 2010.

For the non-believers

Answer:

In the end I was very close with my PS. It was a pretty silly mistake: I had a typo in the namespace. Thanks to Pop Catalin and Madhur Ahuja for pointing it out!

like image 247
Arcturus Avatar asked Dec 21 '10 12:12

Arcturus


People also ask

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 .

What would you set if you wanted to halt the execution of code while debugging?

To set a simple breakpoint in your code, select the far-left margin next to the line of code where you want to suspend execution. You can also select the line and then select F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert Breakpoint.

What are exception breakpoints?

An exception breakpoint tells the debugger to pause whenever a problem is encountered anywhere in your program, so you can evaluate your program's state before it crashes.


2 Answers

There is an 'exceptions' window in Visual Studio ... try Ctrl-Alt-E when debugging and click on the 'Thrown' checkbox for the exception you want to stop on

You are looking for reverse of this: Visual Studio: How to break on handled exceptions?

like image 167
Madhur Ahuja Avatar answered Oct 01 '22 13:10

Madhur Ahuja


Assuming you want to break when the exception occurs unexpected you really should hide the method from the debugger using the [System.Diagnostics.DebuggerHidden] method.

like image 38
user2381484 Avatar answered Oct 01 '22 13:10

user2381484