Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Debug --> Exceptions --> CLR Exceptions

I stumbled on this IDE feature today.

I turned on break into debugger on all exceptions. handled or not handled for System.NullReferenceException.  Doing so freaked me out as a 3rd party control we use went crazy.

After some digging, I figured out exactly what this feature does

"By turning on first-chance exceptions, you are asking the debugger to alert you *whenever* an exception is thrown, *even though there's a catch ready and waiting to handle it*. This is great for seeing the original site of an exception, for example if the exception has been translated or rethrown somewhere along the call stack, or if a catch block is picking up an unexpected exception. But it's completely unrealistic in terms of assessing code correctness or real behaviour. So the fact that your button bar trips first-chance exception handlers does *not* mean there is anything wrong with it or that it has hidden problems waiting to jump out on you. All it means is that it is performing some internal exception handling, which is perfectly reasonable. After all, your code probably contains exception handling: so if you run your code breaking on first-chance exceptions, it too will appear to blow up, but in fact your code is fine, because you catch all those exceptions."

Many thanks to Ivan Towlson at White Carbon for the awesome explanation.

 

1 Comment

  • Well, if your 3rd part component is throwing that many exceptions, even if it is catching them, it is taking a major performance hit. I don't know whether the developers of the component used exception handling when they shouldn't have or not without looking at the code. Probably the best thing to do would be to compare similar products (and your own code) with the Performance admin tool. One of the counters is exceptions thrown/sec.

Comments have been disabled for this content.