5

When the debugging process opens Razor file it is become impossible to make next step (F10, F11) because of VS is blocked by the error "File was modified: Continue or Stop". Also this message appears in the VS Errors list:

enter image description here

Closing of the tab with the "modified" razor file somehow helps - error is gone - and then it is possible to continue debugging.

It seems like VS changes the file by its own, but there is no any sign of this except this message.

Why and where VS adds this 'namespace' ? Knowing this I would add this 'namespace' by myself to my code and then VS will not have a reason to change the code and interrupt debugging.

0

7 Answers 7

2

Seems like it is still open issue: https://github.com/aspnet/Razor/issues/1464

1
  • It's still open after a couple years. I wish they would prioritize this more.
    – staa99
    Nov 6, 2019 at 1:57
1

Try only having @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers in your _ViewImports.cshtml or nothing at all and reproduce to see if it solves your scenario.

1

I had a _ViewImports.cshtml within one View's folder (Views/Foo), and in it had a single namespace that had been commented out, making the import not needed. Removing this file fixed the problem. Then re-adding the _ViewImports.cshtml, even testing with the same commented out namespace, suddenly couldn't reduplicate the problem. Keep in mind I cleaned the solution, deleted obj / bin, etc, many times over before finding this solution, none of which helped. So ... there is indeed something messed up here. But here was one possible source of the problem: an empty view-import, or empty with a commented out portion.

1

I had same problem with you. When your app working, you can't import the namespace to your newly opened class. It will be fixed, when you stop your app.

0

This is, hands down, the most frustrating issue I have with debugging Core apps. I've found that closing all open CSHTML files (and waiting a few seconds for the error to disappear from the Error List window) will fix the issue temporarily, but I usually can't debug in razor in that session any more, and have to at the very least stop and restart the debug session, but more often than not I have to fully restart VS. Just happened to me right now in VS Community 2019 (16.2.2). Haven't updated to 16.2.3 yet, but I'm not holding out hope that they've finally fixed this bug.

0

You can fix it by stopping or restarting IIS Express attached to Visual Studio. It can be stopped by icon available in the taskbar.

0

You can fix it by stopping or restarting IIS Express attached to Visual Studio.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.