14

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.

Thaoden
  • 3,460
  • 3
  • 33
  • 45

6 Answers6

10

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.

Thaoden
  • 3,460
  • 3
  • 33
  • 45
2

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.

newbi
  • 21
  • 1
0

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.

Denis Koreyba
  • 3,144
  • 1
  • 31
  • 49
0

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.

sir_Andros
  • 36
  • 1
  • 4
0

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.

Ondřej
  • 1,645
  • 1
  • 18
  • 29
-1

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...

Daniel Fisher lennybacon
  • 3,865
  • 1
  • 30
  • 38