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 i开发者_开发问答s 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!
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?
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.
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.
This worked for me: [DebuggerHidden]
This is not a bug in the debugger, it was a intentional change. While the behavior is different and can be confusing, it had to be changed in Visual Studio 2010 to support several other scenarios including Silverlight debugging.
- Disable "break on user unhandled exceptions" for the exception types you you are encountering here (via Debug -> Exceptions)
- Disable "break on user unhandled exceptions" for all exceptions (via Debug -> Exceptions)
For more details please refer the link here.
Breaking on exceptions in VS2010
精彩评论