The {not much utilized} Debug->Exceptions… window technique

The Debug-Exceptions… window is a useful tool that at times saves lot of time when debugging. Even though this exists (i think)from Visual Studio 2003, I Still find people struggle a bit with the situation I am going to explain next.

As you know Visual Studio highlights the exception code line when it is not handled. Sometimes we purposely don’t handle exceptions in a method and let the exception thrown to calling functions.



Usually we have a multi-project solution that typically has layers like Business logic, Data access layer, UI, etc. Imagine that you make a call from the UI to a local function and it calls another function in BLL and the call goes deep into layers of your project architecture.

Now, when it is not sure if each of the methods getting called handles exceptions in it or doesn't throw identifiable exceptions.

For instance..

private void Function_A()
        BLLFunction();//this calls few other functions..
    catch (Exception ex)
        //handle exception

Function_A() calls BLLFunction() and it again calls few other functions, but I have handled exceptions only in Function_A(). In this case, whatever method in the call hierarchy triggers an exception, the Visual Studio debugger takes the control to the catch() in Function_A(). Debugging this could be bit hard when the number of functions is more and code is complex. You have to narrow down to the function and line the exception occurred.

Instead, a simple technique can be performed with the Debug-Exceptions window...

If you choose Debug –> Exceptions… a window appears with various categories of exceptions. Check the Thrown check box beside Common Language Runtime Exceptions, and now if you re-debug the project, the line highlighted by debugger will be the exact line where the exception occurs in the exception triggering method.


What happens is, we specify that all Common Language Exceptions are Thrown regardless of whether it is handled or not.

You can even set only the exception you want to be thrown by selecting the exception using the Find.. option as below, this will only throw that specific exception even if it is handled elsewhere and ignore other exceptions.


The User-unhandled option seems bit unclear as of now, and couldn’t put time to find a clear usage scenario now, but thought the above is useful enough to write.

If you like this article..

kick it on    Shout it

I have posted this blog entry as article in too.

Bookmark / Share

Comments for this entry..

Couldnt be written any better about vs-tips . Reading this post rings a bell in my memory of my old room mate! He always kept talking regarding this. I'll forward this informative article 2 him. Pretty certain he will have an excellent read. Thankfulness 4 sharing!

by.. Bret Stayner | May 2, 2010 12:23 | Reply

What do you mean by "not much utilized"? Is there such thing as fully utilized debugging system? I want to more about this two and if there is really a difference among the two can you give the advantages and disadvantages. Thank you for the information. I really appreciated it.

by.. Online Backup | May 24, 2010 13:17 | Reply

I have been browsingonline at least three hours today, so far I never found any exciting article like yours about vs-tips It's pretty worth enough for me. In my view, if every web owners and bloggers made good content as you did, the web are going to be much more practical than ever before.

by.. Mauro Pacholec | May 27, 2010 05:47 | Reply

i will learn step by step here..

by.. paper shredders | May 30, 2010 15:11 | Reply

Gute Idee und außerdem auch schoene Homepage.

by.. search engine rank optimization | May 31, 2010 21:05 | Reply

Having read your post, I have concluded that all the efforts we make they cannot be in vain.

by.. Mario and Luigi | June 5, 2010 08:51 | Reply

Now and then I'll stumble across a post like this and I'll recall that there really are still interesting pages on the web. ^_^. Thanks.

by.. tibia gold | June 8, 2010 05:12 | Reply

test post. to see if this post will go through.wodner why the first one didnt

by.. Sciphone i9 | June 9, 2010 21:13 | Reply

cell phone is tethered to one particular mobile phones service provider. If you try to leave that company, your phone won't work. It'sphones locked. gsm phones If you travel to another country and try to use another company's cell phone

by.. Sciphone i9 | June 9, 2010 21:13 | Reply

Everyone should always be looking to better themselves. This really helps.

by.. Übersetzung Russisch Deutsch | June 17, 2010 05:47 | Reply

Write your comment..

  • Comment
  • Preview