Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core application debug error: "Unable to set the next statement. This file does not exactly match the original version."

While debugging a .NET Core console application in VS 2017, I'm unable to make an edit and then set the next statement. It gives me the error mentioned in the title:

enter image description here

For example, if I set the breakpoint where indicated by the comment, then debug, and modify the string in the first line directly above the breakpoint, I get the error:

static void Main(string[] args)
{
    string x = "foo"; // modify this after debug breaks.
    string y = "bar"; // breakpoint here
}

NOTE: this works as expected in a .NET Framework console application.

When I google the title of this OP, I get zero results, even if I split the two sentences from the error message into separate quoted strings. When I google without quotes, I get a number of results that don't provide an an answer. For example, this one is similar in that it starts out with "Unable to set the next statement" but then the rest is different. This one is also similar but again is different after the first sentence.

What is causing this?

like image 347
rory.ap Avatar asked Nov 19 '18 16:11

rory.ap


1 Answers

I had exactly the same error message. I don't know why it worked but I resolved it by:

  1. Checking Options->Debugging->General->Use the legacy C# and VB expression evaluators.
  2. Running a debug session (where I could then edit and continue).

After unchecking the flag again everything was still working.

like image 190
Matt B Avatar answered Sep 28 '22 00:09

Matt B