Visual Studio 2012 RC breaks on exceptions from within the .NET Framework. How do I make it break on exceptions only in my code?

前端 未结 2 1141
悲哀的现实
悲哀的现实 2021-02-20 15:34

When debugging using Visual Studio 2012 RC with break on exception turned on, Visual Studio breaks on exceptions from within the .NET Framework. How do I make it break on except

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-20 15:58

    Go to Debug -> Exceptions and untick everything. This will tell the debugger to break only on exceptions which are not handled. Unhandled exceptions are ones which are not 'caught', which do not happen within an appropriate try/catch.

    But understand that whichever type of exception happens, if it is not handled, either the debugger will break or application will exit. That's how it's supposed to work. If you expect the exception to happen, wrap culprit code in appropriate try/catch block.

    In this case that would be

    try
    {
    ...
    }
    catch (CultureNotFoundException ex)
    {
       // Show your own message here, or otherwise handle the exception
    }
    

提交回复
热议问题