Unable to set next statement when debugging
Asked Answered
M

1

9

I am debugging my project in VS2015 and an exception is thrown in my code. When I try to set the next statement I get the error message displayed below. When I debug the same solution in VS2013 I am able to set the next statement without any problems. This behavior seems to occur for multiple kinds of exceptions.

Microsoft Visual Studio error window: "Unable to set the next statement. The attempt to unwind the callstack failed."

Example code that I can reproduce the problem with is shown below. When an exception is thrown on the last line in TestMethod1 I can easily move back to the 1st statement in VS2013 but not in VS2015.

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {
        object o = new object();
        o = null;
        var e = o.ToString();
    }
}
Marcille answered 8/9, 2015 at 10:13 Comment(8)
Try creating new project and check if this happens. Alternatively you can reset visual studioUnderhill
WHat was the exception that was thrown in your code?Accalia
@NathanCooper Added infoMarcille
Do you have an (hidden) endless loop in your code?Tver
@Thomas No endless hidden loops.Marcille
And you don't have the smallest clue of where this exception happen?Tver
@Thomas I know exactly where it "happens".Marcille
Then give us the codeTver
F
18

In Exception Settings, you need to enable Break When Thrown for the particular CLR exception type that is being thrown, or <All Common Language Runtime Exceptions not in this list> for custom exceptions. In this particular example, enabling System.NullReferenceException should allow you to set next statement as expected.

If there are particular custom exceptions you want to break on without breaking on all unlisted CLR exceptions, you can add them to the list in Exception Settings and choose accordingly.

I asked about this on MSDN and am relaying info from there. [Source]

Festoon answered 29/9, 2015 at 14:1 Comment(2)
This has irked me for ages. Thanks for taking the time to make this comment.Tercet
I already have this checked for all managed exceptions.Imtiaz

© 2022 - 2024 — McMap. All rights reserved.