Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set next statement when debugging

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();
    }
}
like image 730
user1151923 Avatar asked Sep 08 '15 10:09

user1151923


People also ask

How do you go to the next line while debugging in Visual Studio?

Press F5 until you reach the line of code where you selected Run to Cursor. This command is useful when you are editing code and want to quickly set a temporary breakpoint and start the debugger at the same time. You can use Run to Cursor in the Call Stack window while you are debugging.

How do I move to the next debug point in Visual Studio?

F11/Shift+F11 ⮕ Step into/out This shortcut is to step into the breakpoint or step out of it.


1 Answers

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]

like image 82
Kate Bedenbaugh Avatar answered Sep 16 '22 17:09

Kate Bedenbaugh