Visual Studio 2005 Debugging Tip

Have you ever been debugging an ASP.NET 2.0 application and you see "First Chance Exception XXX" in the Output Window while you are putting the app through its paces in Debug mode, but the IDE never breaks on any of them?

And you are saying to yourself, How can I debug this thing if all I see is cryptic messages in the Output Window but no source code, line numbers or anything else?

What you want to do is tell the Debugger to Break on all Managed Code Exceptions. Here's how:

1) In the IDE, up top, hit "Debug" and Choose "Exceptions". You will see a dialog with a Treeview (collapsed) the second node of which reads "Common Language Runtime Exceptions". At the right will be a checkbox. Check this checkbox. (If you want, you can expand the treenode and pick and choose which kinds of exceptions you want the debugger to break on when thrown). You need to check this (these) because the default behavior is "continue".

In fact, you can even add custom exceptions that aren't in the list, that you want the debugger to break on. CTRL-ALT-E brings this dialog up.

Exceptions Dialog- Click to Enlarge

2)Now when you get an exception, everything will come to a screeching halt and you'll break into the debugger. Ain't technology grand?

Comments

  1. Do you have any ideas why my VS 2005 doesn't show "Exceptions" menu option under Debug menu?

    Fortunately "Ctrl-Alt-E" opens the window, so I just need to remember shortcut.

    ReplyDelete

Post a Comment

Popular posts from this blog

Some observations on Script Callbacks, "AJAX", "ATLAS" "AHAB" and where it's all going.

IE7 - Vista: "Internet Explorer has stopped Working"

FIREFOX / IE Word-Wrap, Word-Break, TABLES FIX