Click here to Skip to main content
13,300,002 members (68,517 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 19 Jan 2005

Visual Studio Exception SetUp

, 19 Jan 2005
Rate this:
Please Sign up or sign in to vote.
Break on Exceptions, like the old days.


You write excellent code with try-catch statements, now how do you get the application to stop when you have an error when debugging?


In previous versions of Visual Studio for Visual Basic, a simple preference setting existed that told the debugger to stop on all errors, unhandled errors, or not to stop. It was easy to adjust and get to. How times changed, and I couldn't find the equivalent for a while, though I didn't look hard. Then came the big moment, I had to debug somebody else's code. I knew Microsoft had to put the setting somewhere, just where did it go?


How do we make debug mode stop on errors?

Here It Is!!!!

While looking at code in Visual Studio 2003, click on the Debug menu. Click on Exceptions. You can also enter Ctrl-Alt-E to bring up the screen, if you haven't associated it to something else.

Basic Exception Dialog

Microsoft took our old Visual Studio VB preference and turned it into something useful. Microsoft likes the idea of Exceptions falling under a category of exceptions. For the highlighted category, you have options when an exception occurs, just like the old days. Most of the time in .NET development, we're worried about Common Language Runtime Exceptions. Let's see what has been categorized under the Common Language Runtime Exceptions category.

As you can see, many exceptions exist in the .NET framework. With each of them, we can use the options provided to break in debug mode. This is a heck of a lot easier than setting debug statements all over the place, now isn't it?

Testing It Out:

I put together a simple project that has a custom exception. Each button makes different kinds of calls.

  • Exception button has a simple code that throws a base Exception and catches it.
  • Not Implemented button throws the NotImplementedException.
  • Custom button throws and catches the CustomException.
  • Custom No Catch button throws the CustomException, but doesn't catch it.
  • Custom Throw Below calls a function that throws the CustomException and catches it.
  • Custom Throw Catch Below calls a function that throws the CustomException, catches it, and throws it to be caught by the button code.

That's not all the possibilities, but it gets us started by giving us a chance to experiment with the Exception dialog. To really make the dialog work, make sure to add the CustomException under the Common Language Runtime Exceptions.

Here it is set up to break whenever the CustomException is thrown.

And there you go, keep an eye on when the code actually breaks.

Also, if you have multiple projects, you may run into some unusual errors when you start your application. The errors actually make sense, but are beyond this beginner level article. To stop some of the errors, you just have to look them up in the Exception Dialog and set the action to take to "Continue".

That's it folks. Simple.


None yet.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Tim Schwallie
Team Leader
United States United States
A biography in this little spot...sure.
I've worked at GTE HawaiianTel. I've worked at Nuclear Plants. I've worked at Abbott Labs. I've consulted to Ameritech Cellular. I've consulted to Zurich North America. I've consulted to International Truck and Engine. Right now, I've consulted to Wachovia Securities to help with various projects. I've been to SHCDirect and now at Cision.

During this time, I've used all kinds of tools of the trade. Keeping it to the more familier tools, I've used VB3 to VB.NET, ASP to ASP/JAVASCRIPT/XML to ASP.NET. Currently, I'm developing with C# and ASP.NET. I built reports in Access, Excel, Crystal Reports, and Business Objects (including the Universes and ETLS). Been a DBA on SQL Server 4.2 to 2000 and a DBA for Oracle. I've built OLTP databases and DataMarts. Heck, I've even done Documentum. I've been lucky to have created software for the single user to thousands of concurrent users.

I consider myself fortunate to have met many different people and worked in many environments. It's through these experiences I've learned the most.

You may also be interested in...

Comments and Discussions

GeneralLook before you leap! Pin
Hrusikesh28-Jan-05 5:04
memberHrusikesh28-Jan-05 5:04 
GeneralRe: Look before you leap! Pin
Tim Schwallie2-Feb-05 19:41
memberTim Schwallie2-Feb-05 19:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 20 Jan 2005
Article Copyright 2005 by Tim Schwallie
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid