Don't Stop Debugger at That Exception When It's Thrown and Caught

Don't stop debugger at THAT exception when it's thrown and caught

If I recall correctly you can use a DebuggerStepThrough attribute on the method that contains the code you don't want exception to fire. I suppose you can isolate the code that fires the annoying exception in a method and decorate it with the attribute.

Exception seems to be thrown repeatedly when debugging

Is this just because of a special behaviour of the debugger? Or is
that exception also thrown repeatedly when i am not debugging it?

The Visual Studio debugger doesn't let the thread die due to the unhandled exception. The exception isn't being rethrown, the debugger doesn't let the line continue since it will crash the process. If the debugger wasn't attached, then IIS would give you the yellow screen of death and the event log would have been populated with the information contained within.

This is the same behavior for all applications, web or client side while debugging.

Exception seems to be thrown repeatedly when debugging

Is this just because of a special behaviour of the debugger? Or is
that exception also thrown repeatedly when i am not debugging it?

The Visual Studio debugger doesn't let the thread die due to the unhandled exception. The exception isn't being rethrown, the debugger doesn't let the line continue since it will crash the process. If the debugger wasn't attached, then IIS would give you the yellow screen of death and the event log would have been populated with the information contained within.

This is the same behavior for all applications, web or client side while debugging.

How to prevent break on specific exception if it's handled

You can do this by setting the debugger to break on user unhandled exceptions.

Go to Debug -> Exceptions, Common Language Runtime Exceptions, de-tick (uncheck) the Thrown box. Of course you can get very precise with what you want to break on by drilling down into that list. Be aware that this setting takes effect across the whole solution, you can't set it per class or method. If you do want to be more selective per method, then consider using compile directives to not include that bit of code during debug time.

As for the DebuggerStepThrough attribute, that is to prevent breaking on break points, nothing to do with breaking on exceptions.

visual studio: tell in part of the code to don't exception-break when debugging

In addition to @abelenky's answer, I'd like to note that there are certain Exceptions that Visual Studio won't let you disable (C++ Exceptions, GPU Memory Access Exceptions, etc). You then have to look at using the System.Diagnostics attributes to bypass these Exceptions in the debugger.

DebuggerHiddenAttribute and DebuggerStepThroughAttribute are two of the attributes that can be used to tell the debugger to skip certains sections of code.

public string ConnectionString{
[DebuggerStepThroughAttribute()]
get {
// Implementation here;
}
}

Above example taken from:
Using Attributes to Improve the Quality..

[DebuggerHiddenAttribute]
static void Main(string[] args) {
// Implementation here;
}


Related Topics



Leave a reply



Submit