VS 2017 immediate window shows "Internal error in the C# compiler"
Asked Answered
K

6

15

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.

Krumm answered 26/4, 2018 at 9:32 Comment(3)
Here is an (by now unsolved) developer community issue: developercommunity.visualstudio.com/content/problem/205713/…Glans
Rebuilding the project worked for me.Browse
This is now also tracked as a github issue: github.com/dotnet/roslyn/issues/32249Krumm
K
11

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.

Krumm answered 26/4, 2018 at 9:39 Comment(0)
C
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.

Chellean answered 29/8, 2018 at 10:50 Comment(0)
J
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.

Jacket answered 19/6, 2018 at 7:55 Comment(0)
L
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.

Logorrhea answered 3/5, 2019 at 15:37 Comment(0)
C
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.

Cablegram answered 24/8, 2022 at 11:17 Comment(1)
This is by far the best comment I have ever read on Reddit.Perrone
G
-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...

Glans answered 28/8, 2018 at 14:7 Comment(2)
@Krumm Did you debug an ASP.NET app? I do and use the approach regularly with success...Glans
ASP.NET Core - using Visual Studio 2019 RC, evaluating simple expressions works again as expected.Krumm

© 2022 - 2024 — McMap. All rights reserved.