Skip to content

Always Set Stop On Exception While Doing Debugging in Visual Studio 2005 or 2008

Updated: at 02:12 PM

One of the tricks I've learned over time is to always set visual studio to stop on a thrown exception.  Normally, during running of a .net application, unhandled exceptions are simply processed and absorbed quietly.  For the most part, this is good because you do not want your users to see error messages all the time, and likely what is being thrown is not interesting anyhow.  It is however bad because throwing exceptions is very time consuming for the application as well as it may actually be something important.

To keep this from happening, my "best practice" is to go into the menu choice Debug/Exceptions as follows:

Debug Excetpion Menu Choice

Then, you will get the following dialog.  Make sure to check everything as show below:

Debug Excetpion Menu Choice

Then, when you hit an exception while debugging, the debugger will stop on the offending line so you can figure out if you should be surrounding this with a try/catch, or whether it's just an oversight you need to fix.

Good luck with this!  It's helped me a huge amount in finding bugs I would have likely found later and much more painfully.

Check out the ORM (Object Relational Mapper) PRISMA. The database access method I use in all my projects