8

I know Exception Handling is a very important thing and we are doing it in all our projects. The main reason is to log errors that occur at the customers. This works fine and is not problem at all.

But while I am still coding and running the application with Visual Studio I don't want any exception handling at all. I want the debugger stop right at the line the application crashed and not in some error logger I wrote. And I don't want to forward exceptions with throw!

But I am still looking for an easy way to do that. I could write countless #if Debug or #if Release statements all around the try/catch but that is not what I want to do. Is there any other way to deal with this problem?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
TalkingCode
  • 13,407
  • 27
  • 102
  • 147
  • Why can't you code with the existing exception handling ? – JonH Mar 02 '10 at 16:29
  • @ JonH -- Presumably there's a performance concern. Exception-handling is convenient and versatile, but comes with a price. – Hardryv Mar 02 '10 at 16:34

5 Answers5

16

(1) Open Visual Studio with your project
(2) Debug Menu, Exceptions
(3) For the exception types you care about tick the Thrown box.

This will make it so that whenever an exception of the types chosen is thrown you will automatically break into it. When you want to go back to regular debugging go back to that same Exceptions window and click "Reset All" and you'll go back to the default settings.

Restore the Data Dumps
  • 38,967
  • 12
  • 96
  • 122
  • The Find... button is also very good even given a partial name match. – Robert Davis Mar 02 '10 at 17:05
  • I just had the issue that I didn't have a "User Unhandled" column. This one helped me: http://stackoverflow.com/questions/4560497/exception-window-in-vs-net-2010-is-missing-the-user-unhandled-column – TweeZz May 26 '11 at 10:46
9

You can configure the Visual Studio debugger to break when the exception is thrown. See the menu Debug -> Exceptions.

For additional information:

How to: Break When an Exception is Thrown

João Angelo
  • 56,552
  • 12
  • 145
  • 147
1

in visualstudio Menu Debug->Exception Check all under the column "Thrown". By default, All items will be check for column "User Unhandled"

This way, debugger will break whenever the exception is thrown.

Note: this will not be part of project property

SysAdmin
  • 5,455
  • 8
  • 33
  • 34
  • I just had the issue that I didn't have a "User Unhandled" column. This one helped me: http://stackoverflow.com/questions/4560497/exception-window-in-vs-net-2010-is-missing-the-user-unhandled-column – TweeZz May 26 '11 at 10:45
1

Debug > Exceptions (Ctrl+Alt+E), check Thrown on Common Language Runtime Exceptions to throw all exceptions, or select the exceptions you want manually with find all. After you're finished debugging hit Reset All to get back to default.

Lee Treveil
  • 6,655
  • 4
  • 30
  • 29
0

in the VS editor you can set without putting the braekpoints on the type of exceptions the codebreaks - you can set it up using the debug menu -> exception this will allow you to do what you want.

ashish jaiman
  • 389
  • 1
  • 4