Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 17 breaking on all exceptions

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.

like image 683
MetaColon Avatar asked Jun 27 '17 22:06

MetaColon


People also ask

How do I break all exceptions in Visual Studio?

Tell the debugger to break when an exception is thrownIn the Exception Settings window (Debug > Windows > Exception Settings), expand the node for a category of exceptions, such as Common Language Runtime Exceptions. Then select the check box for a specific exception within that category, such as System.

How do I stop Visual Studio from breaking on exception?

To turn off stop on exceptions press " Ctrl + Alt + E ". This will open the Exceptions window . Untick "Common Language Runtime Exceptions - Thrown". That would prevent it from pausing from within the delegate, but not when it's rethrown on Wait .


1 Answers

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

like image 116
ILMTitan Avatar answered Oct 03 '22 13:10

ILMTitan