Saving Debug > Exceptions settings

Update: See Fixing Debug > Exceptions settings programmatically for a better solution.

I prefer debugging with the “Break when an exception is Thrown” setting enabled in the Exceptions dialog; when a problem occurs, you get to look at the stack and variables in the exact place it happens.

Visual Studio Exceptions Dialog

Unfortunately, there are a number of “vexing exceptions” thrown and caught within the framework that cause spurious breakpoints. (These include NotSupportedException when loading images in WPF, ConfigurationErrorsException when starting the program, etc.) These need to be individually disabled.

Even more unfortunately, Visual Studio has a tendency to clear all these settings without telling me, so the next time I start debugging, I have to set them up all over again.

I finally found that these settings are stored in the SolutionName.suo file that lives alongside your .sln file. Once you’ve configured the Exceptions dialog to your liking, close all the open windows, then exit Visual Studio. Make a backup of the .suo file and restart Visual Studio. Whenever VS loses your settings, close it down, overwrite the real .suo file with your backup, restart VS, and you’re back to debugging the way you want to. (Of course, you will lose the open windows, active project, and other user-specific solution settings; however, it takes me less time to reconfigure those than to re-set all the exceptions.)

Posted by Bradley Grainger on January 28, 2010