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 1142
悲哀的现实
悲哀的现实 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
    }
    
    0 讨论(0)
  • 2021-02-20 16:09

    I believe all you need to do is go to

    Debug -> Options -> Debugging and check Enable Just My Code (Managed Only)

    0 讨论(0)
提交回复
热议问题