Visual Studio 2015 break on unhandled exceptions not working

前端 未结 12 1786
别那么骄傲
别那么骄傲 2020-11-30 23:36

Visual studio used to have a specific checkbox to \"Break on Un-handled exception\". In 2015 this has been removed (or moved somewhere I cannot find it). So now my convert

相关标签:
12条回答
  • 2020-11-30 23:45

    I had the same issue and I managed to solve this by doing this -

    1. Press Ctrl + Alt + e to bring up the Exception Settings window.
    2. Tick Common Language Runtime Exceptions.

    That's it!

    I was inspired this post since I am using a x64 version of Windows.

    0 讨论(0)
  • 2020-11-30 23:45

    Try following the instructions:

    1. In the Exception Settings window, open the context menu by right-clicking in window and then selecting Show Columns. (If you have turned off Just My Code, you will not see this command.)
    2. You should see a second column named Additional Actions. This column displays Continue when unhandled by user code on specific exceptions, meaning that the debugger does not break if that exception is not handled in user code but is handled in external code.
    3. You can change this setting either for a particular exception (select the exception, right-click, and select/deselect Continue when Unhandled in User Code) or for an entire category of exceptions (for example, all the Common Language Runtime exceptions).

    https://msdn.microsoft.com/en-us/library/x85tt0dd.aspx

    0 讨论(0)
  • 2020-11-30 23:46

    There's definitely some bug in Visual Studio that can cause it to get stuck requiring a restart. Even VS2015.

    I had a single threaded situation where a NullReferenceException was getting caught by an 'outer' handler (still in my code) even though I asked for it to break when it was raised.

    I realize this is a 'handled' exception and you're talking an 'unhandled' one - however I'm pretty sure that sometimes a quick restart of VS will fix this, if IISRESET doesn't.

    0 讨论(0)
  • 2020-11-30 23:48

    There's a new window called "Exception Settings" that appears in the lower right pane by default when you begin debugging. It has all of the options you would expect.

    You can bring it up with CTRL+ALT+E

    This allows you to cherry-pick which exceptions cause a break in the debugger.

    The key, though, is that you can also set whether these exceptions always break, or only break when it's an unhandled exception -- but setting this is not very intuitive.

    You will need to first check "Enable Just My Code" under Tools > Options > Debugging.

    This then allows you to right-click the column header (Break When Thrown) in the new Exceptions Settings window, and add the "Additional Actions" column, which then allows you to set each exception as "Continue when unhandled in user code".

    So just right-click an exception or an entire group and disable the "Continue when unhandled in user code" flag. Unfortunately, the "Additional Actions" column will show up empty which is the same as "Break when unhandled in user code".

    More on this here:

    http://blogs.msdn.com/b/visualstudioalm/archive/2015/02/23/the-new-exception-settings-window-in-visual-studio-2015.aspx

    0 讨论(0)
  • 2020-11-30 23:50

    For googler that wants to break only when the exception concerns their code, there is an option in Visual Studio 2015: Options->Debugging->General->Just My Code. Once checked, it allow to do not break when the exception is managed (thrown and catched) outside your code.

    0 讨论(0)
  • 2020-11-30 23:59

    When I upgraded to VS2015, I also had issues where exceptions used to "break" the application, but are now ignored and passed right over. There are times when we want our code to intentionally throw exceptions in places where we want the code to stop, rather than continue. We always use the phrase Throw New Exception("Message") to get our code to intentionally break:

        If SomethingReallyBad = True Then
            Throw New Exception("Something Really Bad happened and we cannot continue.")
        End If
    

    With VS2015, the classic "System.Exception" is what is thrown when we say Throw New Exception. Therefore, we needed to check the "System.Exception" tick in the new Exception Settings:

    Check the System.Exception Box

    Once checked, our code did as expected.

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