VS 17 breaking on all exceptions

11,805

Solution 1

I was having a similar problem.

I fixed it by unchecking "Break when exceptions cross AppDomain or managed/native boundaries" in Tools > Options > Debugging > General

Solution 2

I fixed it by unchecking Enable Just My Code in Tools > Options > Debugging > General

Solution 3

I can't confirm whether this happens with other project types, but it happens to me consistently with (Visual Studio Tools for Python) VSTP.

Although it is less than satisfactory, it can at least silence the exceptions and allow you to continue working in peace until a better solution surfaces. In my case, it was nearly impossible to debug my code, since StopIteration breaks during every iteration.

Select Debug > Windows > Exception Settings or press Ctrl-Alt-E. Y

Exception Settings

Right click anywhere on the Window and select Show Columns > Additional Actions. You will have an "Additional Actions" column appear if it doesn't already.

Right click on a specific exception you want to silence or click the top level checkbox to select an entire category of exceptions, i.e. Python Exceptions. Click Continue When Unhandled in User Code.

Repeat for each additional exception or category of exceptions.

Share:
11,805
MetaColon
Author by

MetaColon

Currently coding for fun, university and as part time employee. My preferred pronouns are he/his. Coding experience since 2015 ;)

Updated on June 06, 2022

Comments

  • MetaColon
    MetaColon almost 2 years

    Visual Studio 2017 is (kind of suddenly) breaking on all exceptions. That means, if I deactivate them in the exceptions settings (pressing CTRL + ALT + E while debugging), the debugger still breaks on them. I don't know wether this is just a bug of VS I can't change and therefore have to live with, or wether there is a simple solution for it.

    This is the exception settings window: the exception settings

    and this the exception VS breaks on: the exception

    By the way, I also tried that beautiful minus (nothing happens if I press it) or adding a impossible condition (VS still broke on the exception).

    I also tested other exceptions (by simply throwing them), which I deactivated before, and they get thrown as well and I tested the same issue in other projects, where it appeared as well: the issue in other projects

    I actually even put the whole stuff into a try catch statement but VS still breaks:

    InitializeComponent ();
    try
    {
        var t = new Thread (() =>
        {
            while (!IsHandleCreated) {} //It breaks here (similiar to the screenshots)
            while (true)
                Invoke (new Action (() => Size = new Size ()));
        });
        while (true)
        {
            t.Start ();
            Thread.Sleep (100);
            t.Abort ();
        }
    }
    catch (ThreadAbortException) { }
    

    It doesn't appear in other IDEs (like Rider) on my PC and doesn't occurr on other PCs in VS. It didn't always occurr on my PC, it just started recently and only in debugging mode. And if I continue the execution (with F5) it just continues normally.

    EDIT As I put the try catch inside the thread it behaved a little bit different (I'm sorry for putting pictures in here, but I think they're more expressive in that case): new exception location

    Can anybody explain this behaviour?

    EDIT It seems to be normal for ThreadAbortExceptions to break again at the end of a catch statement. However, VS still shouldn't break on this exception at all.