Reputation: 3580
I use Visual Studio 2017 (15.6.6). When debugging, I try to evaluate simple expressions like int a = 2;
in the immediate window. An error
Internal error in the C# compiler
is thrown.
I tried to enable Use Managed Compatibility Mode
as hinted at in this question but it didn't help.
Thanks for any help.
Upvotes: 15
Views: 13610
Reputation: 1673
It is happening in Visual Studio 2022 17.3.2 too and it can be found "Closed, not enough info" on feedback hub. As always, incompetent outsourced india strikes again.
Anyway stopping debugging and rebuilding solution works. It have something to do with completely f****d and useless Hot Reload.
Upvotes: 0
Reputation: 36
I've got the same error when deal with own NuGet package. In my case VS resolve a path to the copy of my assembly in "%userprofile%.nuget" folder instead of build output folder.
Currently, I don't known how to prevent this miss-resolving for new project types, where no hint is specified for references, but there's simple workaround: just remove unpacked copy of package from %userprofile%\.nuget\packages\%yourpackage%
before debug.
Upvotes: 0
Reputation: 21
In my case, the problem was occurring in a particular assembly. When we looked at the assembly information, (from the Solution Explorer, right click on project, select Properties, then click on Assemble Information), it was all blank.
So we gave it a Guid, then re-built and it worked.
Upvotes: 2
Reputation: 4194
Clearing the directory C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
solved the issue for me. I'll try to build a repo if the issue appears again...
Upvotes: -1
Reputation: 3718
I had the same issue. Don't know if it's your option but for me it was the next issue: instead of "Debug" version the "Release" was turned on. So as soon as I switched back to debug I got rid of this error.
Upvotes: 0
Reputation: 3580
Searching further I found this issue on GitHub where an answer recommends to also check Use the legacy C# and VB expression evaluators
. Visual Studio gives me a warning about checking this option, but turning this on I can evaluate expressions in the immediate window again.
It is even possible to turn off the Use Managed Compatibility Mode
again.
Update: Notice though that using the legacy expression evaluators prevents me from inspecting local variables at debug time, so I wouldn't call it a solution.
Upvotes: 11