Search code examples
c#multithreadingexceptionvisual-studio-debugging

Avoid debugger halt on caught exception in thread


Is it possible not have the debugger stop at the throw statement, while keeping the same functionality? I've asked around and it seems not, but I thought I'd give stackoverflow a try before I accept that's it's not possible.

class Program
{
    static void Main(string[] args)
    {
        var o = new MyClass();
        var t = new Task(o.DoStuff);
        t.Start();

        try
        {
            t.Wait();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
        Console.ReadKey();
    }
}

public class MyClass
{
    public void DoStuff()
    {
        throw new Exception("Testing"); // debugger stops here!
    }
}

Solution

  • Open Exceptions windows with Ctrl + Alt + E in Visual Studio. Click on which exception you want to unhandled.

    Also check: Visual Studio: How to break on handled exceptions?

    enter image description here