"Internal error in the expression evaluator"

I've encountered a problem in expression evaluator of visual studio 2015 that says "Internal error in the expression evaluator", after some investigations I found that this is caused by an assembly that is loaded using reflection. This assembly wouldn't throw any exceptions but after that, vs exp evaluator will fail. This is not the only assembly that I load, there are some good working ones that don't influent the evaluator.

To overcome this issue I had to check 'Menu > options > debugging > Use Managed Compatibility Mode' but this disables the 'Edit & Continue' feature, what can I do?

Properties of the causer assembly:

  • its name is the same as the main assembly (i changed its name but nothing happened)
  • all of my projects are using dotNet 4.5
  • all root namespaces are same (all of the assemblies are so)

Thanks!


That sounds like a bug in the expression evaluator. For a better workaround, instead of checking "Use Managed Compatibility Mode", check "Use the legacy C# and VB expression evaluators". This should enable you to continue using Edit and Continue as well as other features added within the last few releases.

In terms of the "Internal error in expression evaluator", can you please open an issue by going to Help -> Send Feedback -> Report a problem? That will help us fix the problem in future releases.


Just extending on the solution provided by Patrick Nelson. For Visual Studio 2015+ as inquired, the steps are as follows.

If you're debugging at the moment, this option will be unavailable. Stop the debugger.

Go to Tools -> Options

VS Options

and here under the Options select Debug -> General and scroll down to find the ...legacy C# expression.. option:

VS Options Debug Legacy options

More information is provided here:

Switching to Managed Compatibility Mode

Note: There are also some serious drawbacks that occur from switching to the legacy mode. Especially Runtime Reflection of the implemented Interfaces becomes almost an impossibility or extremely inconvenient. There are also other Reflection methods which will throw errors.


I finally figured out what created this problem in my Visual Studio!

The quick fix is to delete the debug object favorites from the "Documents/Visual Studio xx/Visualizers" folder and restart Visual Studio.

enter image description here When you "pin" a variable in the debugger, Visual Studio saves a 'favorite' json object for it.

It appears that there is a bug in Visual Studio which corrupts the 'favorite' for some child variables that are dynamic in nature (not exactly sure of the conditions though). enter image description here


For me checking "Use Managed Compatibility Mode" option worked. I was also seeing question marks when hovering over variables, instead of properties and values