How to tell the debugger to ignore breaking on thrown exceptions?
Solution 1
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?
Solution 2
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.
Solution 3
Debug + Exceptions, click the Add Button. Set the type to "Common Language Runtime Exceptions" and the Name to the full name of the custom exception, including the namespace name. You can now untick the Thrown box for this one, expand the node first if necessary.
Solution 4
This worked for me: [DebuggerHidden]
Arcturus
I work as a freelance software developer in the Netherlands, specialized in both C# and Java.
Updated on May 12, 2020Comments
-
Arcturus about 4 years
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.
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!
-
Alex Klaus over 10 yearsDoesn't work, because it stops debugger on one level up in callstack from the method with [DebuggerHidden]. It may work for event handlers though.
-
crokusek over 7 yearsThere seems to be a bug with this approach in MSVS 2015 stackoverflow.com/questions/39382551
-
crokusek over 7 years@Klaus, agree, I'm not alone: stackoverflow.com/questions/39382551
-
msteel9999 over 7 yearsSpot on worked like a charm. Had an exception thrown every time I debug for 6 months.
-
BrainSlugs83 almost 4 yearsThat change really sucks, because I want to break on unhandled exceptions, but these exceptions are definitely handled.