0

I am unable to move the next statement pointer in VS2022 outside the catch block if an Exception is thrown.

If I run this code in a VS2022 (17.14.4) Unit Test Project (.Net 4.81), set a break point on the catch statement and as soon the breakpoint is hit, try to move the next statement back to one line within the try block I get an error window with the message: <<Unable to set the next statement. The attempt to unwind the callstack failed. ....>>

If I do the same in a VS2019 (16.11.47) Unit Test Project I can move the next statement pointer wherever I want. I compared the settings in both environments and did not find differences in Options or Exception Settings.

I encounter this problem even if I open the same Project from both version of Visual Studio, or if I create a plain vanilla Unit Test project for both versions.

[TestMethod]
public void TestMethod1()
{
    try
    {
        if (1 != 0) throw new Exception("Not equal!");
    }
    catch 
    {
        throw;
    }
}

What do I have to change to get the same behaviour as in VS2019?

4
  • Debug vs. Release build? C++ could probably optimize everything away, so there are no lines left. Not sure what C# does nowadays. Commented Jul 23 at 14:13
  • It's Debug build (C#). This code is just a sample. I have the problem in all projects, regardless if console application, class libraries, unit tests. And my colleages using VS2022 have the same problem. Commented Jul 24 at 19:55
  • I can reproduce and confirm the behavior in VS 17.14.9 in a .NET 8 app as well. Commented Jul 25 at 5:48
  • I'm having exactly the same issue with VS 2022. Any update on this? Commented Sep 5 at 5:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.