views:

369

answers:

4

Is there any addon by which I can disable all catch blocks temporarily. I'm maintaining an application and I need to find out where exactly it is throwing exception. Someone has done error handling is done is all layers to make my job tough :(

+15  A: 

I don't know a way to disable catch blocks but what you are trying to achieve can be done easily a VS option in exceptions dialog:

Debug -> Exceptions -> CLR Exceptions -> Check the "Thrown" checkbox.

This way, VS will break immediately when an exception is being thrown before running any catch block.

Mehrdad Afshari
Note, expect to have a lot of false positives before you find the problem exception, unless you know the exact type of that exception.
Richard
thank you very much!!!
iJeeves
I have been looking for that for ages! Turns out VS2005 doesn't have the Exceptions... Option in the debug menu by default, but you can add it by customizing the toolbars.
Pondidum
Andy: I'm sure it has it somewhere in a menu. Even VS2002 had it. Haven't seen them for a long time...
Mehrdad Afshari
Mehrdad: I get that feeling with a lot of menu options. I guess its due to VS2008 at home and VS2005 at work...
Pondidum
@Andy: VS2k5 does have the Exceptions menu (C++ project) Debug -> Exceptions or Ctrl+D,E (from C# keyboard mapping)
Simeon Pilgrim
+1  A: 

You don't need to disable all catch blocks to identify where an exception is first thrown from - in the debugger. If you open the Exceptions dialog in VS, you can configure the debugger to catch an exception either when it's unhandled (the default), or when it is first thrown. This is the simplest and least intrusive way to do it.

The Exceptions dialog is accessible from the Debug menu.

LBushkin
+1  A: 

You should use the Debug > Exceptions menu to bring up the Exceptions dialog, and select the checkbox "Thrown" on any kind of exception for which you want the development environment to break during debugging.

You'll find that VS will break when the particular exception (or any of its subclasses) is thrown, before exception handling takes place.

This will solve your problem.

Dave Van den Eynde
A: 

What I find often more interesting is the Stack window.

When in debug mode, running a project, go

Debug => Window => Call stack (Ctrl+d, C)

Now you can see what steps where take to come here and you can d-click them to go to the code line. I find it really handy.

borisCallens
Yes, but you don't have a call stack until you hit a break.
Dave Van den Eynde
Don't know about all exceptions (should check it out), but I know it works for stackOverflows (the exception)...
borisCallens
Yeah, of course, since an exception will break you into the debugger, providing a call stack. This question is how to break on exceptions in the first place.
Dave Van den Eynde
If I'm not mistaking, the problem in the OP was that an exception was thrown, but it was not at the origin. So what I'm suggesting is to follow down the stack trace to see where the exception is comming from..
borisCallens