Is it possible to suppress first chance supressions in Visual Studio (C# debugger) for specific lines of code?
I want to use first chance exceptions in the debugger, but there are about 50 first chance exceptions I need to go through every debug session before I get to the interesting code.
Currently, I turn off first chance exceptions and then manually turn them on, but that’s a hassle and a time sink.
DebuggerNonUserCodeAttribute Class
As of .NET 2.0, if you mark an method with the [DebuggerNonUserCode] attribute, the debugger will skip first chance exceptions in it.
Quote from MSDN link (emphasis added is mine):
There is no runtime behaviour apart from debugging, associated with this attribute.
However if you have just one method with certain lines intended for inclusion in Visual Studio’s first chance exception handling mechanism, and other lines to be excluded, there’s likely not a solution at this level of granularity. You can always refactor a large method into multiple methods and use the attribute on select ones.
Additional Info…
Example usage from this article
The article shows related VS project options that might be useful.
