dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
506 stars 196 forks source link

Having breakpoints in cshtml files that are not open in the editor breaks debugging #5582

Closed ajaybhargavb closed 3 years ago

ajaybhargavb commented 7 years ago

Steps to reproduce:

I think this is probably a tooling issue but I am not sure.

VS version: 26621.2.d15rel

rynowak commented 7 years ago

Is this with Pages? or regular Razor files?

ajaybhargavb commented 7 years ago

Regular razor files. I didn't test with pages.

rynowak commented 7 years ago

image

I get this message in the error list.

My guess is that something is rev-ing the generated code, which is causing the ENC error.

rynowak commented 7 years ago

We should figure out if this is related to how we do checksums. Is this an artifact of having checksums in the design time code?

ajaybhargavb commented 7 years ago

Is this an artifact of having checksums in the design time code?

No. We do not generate checksums in design time.

ajaybhargavb commented 7 years ago

@alexgav is taking a look.

ajaybhargavb commented 7 years ago

This is being tracked here

sotoabraham commented 5 years ago

This still lives huh? Been a couple years I think. Well if it helps, I have this issue whenever I include namespaces and/or add a "addTagHelper" to the _ViewImports.cshtml file in a project.

When I leave only the "@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers" line in there, I have no issues when I place a breakpoint in a razor file or if I have Exception settings set to "Break When Thrown" and an exception occurs in a razor file.

But the moment I add a namespace or other tag helper to _ViewImports.cshtml I'm not able to continue debugging, (this may be dependent on the scope of the taghelper or the need of the namespace for that razor file/view).

KPatel91 commented 5 years ago

@sotoabraham thanks for this - it's a bit strange that this is still an issue but indeed on netcore2.2 my project uses SpaServices tag helper and if I remove it, I have no issues debugging / even having cshtml files open.

It's a weird one that's plagued my new clients project for years but nobody has ever bothered looking into it, their workflow has literally been "place your breakpoint, close the file, and re-start the project" which is a horrible workflow lol.

copernicus365 commented 5 years ago

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, I just wanted to add this little extra bit if it helps to solve the problem.

TPucke commented 5 years ago

I am having this issue as well. It started when I started working on asp.net core 3.0 applications and VS 2019. My solutions are extended from the standard web application project templates. I can just open a fresh IDE, go straight to a debug execution, and if I hit a breakpoint I often can't resume. Same warning ENC0021 as others have reported in my Error List panel and same dialog box telling to me Edit or Stop.

Funny thing today, I was staring at the warning in anger and it disappeared before my eyes, no interaction by me at all. I hit F5 and could continue. That has happened exactly once...

I don't believe this is a design time issue. To me it behaves as if the debugger thinks code files are being written to at the time a breakpoint is hit.

fleckert commented 5 years ago

Any updates regarding this...?

mkArtakMSFT commented 4 years ago

@ajaybhargavb the referenced issue has been resolved. Should this be closed already?

ajaybhargavb commented 4 years ago

This has been fixed.