Is there a pragma or debugger attribute which will allow the debugger to not break on the throwing of a specific exception even though under the Debug >> Exceptions menu I've told it to break when any CLR Exceptions are throw?
In general while developing I like to have it break on exceptions while debugging so that I can immediately inspect them. Sometimes there are some isolated cases where it is known that this block of code occasionally throws exceptions and I've handled it in with a try-catch. See the answer to this question where the consensus was that try-catch is the most correct situation.
I'd like to be able to set an attribute on the method (something analogous to System.Diagnostics.DebuggerHiddenAttribute) which just ignores any exceptions thrown in the method.
BTW, I'm currently experiencing this in Visual Studio 2008, but I'm guessing there is either an answer for all versions or none.
To turn off stop on exceptions press " Ctrl + Alt + E ". This will open the Exceptions window . Untick "Common Language Runtime Exceptions - Thrown". That would prevent it from pausing from within the delegate, but not when it's rethrown on Wait .
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 .
An exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another. VB.Net exception handling is built upon four keywords - Try, Catch, Finally and Throw.
The direct answer can be found under Exceptions menu item of the Debug menu. This is a per solution/project setting. (Tools > Option > Debugging is a system-wide setting.) See the help topic Visual Studio Debugger, How to: Break When an Exception is Thrown at http://msdn.microsoft.com/en-us/library/d14azbfh.aspx for details. The Exceptions dialog allows you to set which exceptions are thrown or which exceptions break into the debugger.
I find I get more use out of the DebuggerStepThrough
attribute.
In general, I leave throwing exceptions to the default (Debug > Exceptions user-unhandled checked and Thrown unchecked) and add the DebuggerStepThrough
attribute for methods where I am not interested in stepping through nor am I interested in any exceptions being thrown within that method. I rarely use DebuggerHidden
, and get more use with DebuggerNonUserCode
in library code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With