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

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!

meJustAndrew's user avatar

meJustAndrew

5,6677 gold badges53 silver badges71 bronze badges

asked Dec 31, 2015 at 10:55

Mehran Khazaeizadeh's user avatar

5

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.

answered Dec 31, 2015 at 18:50

Patrick Nelson - MSFT's user avatar

9

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.

StayOnTarget's user avatar

StayOnTarget

11k10 gold badges49 silver badges75 bronze badges

answered Aug 19, 2016 at 10:12

Lorenz Lo Sauer's user avatar

Lorenz Lo SauerLorenz Lo Sauer

23.1k15 gold badges84 silver badges87 bronze badges

2

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

answered May 13, 2021 at 22:01

neoscribe's user avatar

1

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

answered Nov 28, 2016 at 21:05

Talha Anwer's user avatar

I resolved this issue by simply resetting my visual studio settings by going to: to Tools->Import and Export Settings and selecting to reset to default settings

answered Apr 11, 2018 at 12:58

Brandon's user avatar

I had the same issue with VS2019. I ended up deleting my Documents/Visual Studio 2019 folder. Hope this might help someone, one day. Cost me a day.

PS. Probably not required to delete all, and of course not your projects (if they’re in there), but in my case, everything in there was autogenerated by VS.

I of course tried all solutions mentioned here, and even reinstalling VS didn’t work. Refactoring the class to another name was the ‘trigger’ which made me think there must be some cache, despite cleaning symbols and such didnt work.

answered Dec 17, 2020 at 11:10

Honnes's user avatar

HonnesHonnes

3251 silver badge12 bronze badges

3

In my case I was trying to evaluate lambda expression on List<> and had such error («Internal error in the expression evaluator»). I was using VS2015, so lambda expressions were allowed. It turns out expression evaluator was lacking of Linq library. I added

using System.Linq;

to my current class and voilà! Lambda evaluated.

answered Nov 9, 2016 at 14:03

pilak's user avatar

pilakpilak

413 bronze badges

I encountered the «internal error in the expression evaluator» error when I was debugging in release mode instead of in debug mode. I had changed it to Release when publishing to production and forgot to change it back to Debug.

Release Mode

Debug Mode

answered Nov 18, 2016 at 18:52

MsTapp's user avatar

MsTappMsTapp

4491 gold badge10 silver badges17 bronze badges

Check your use of the [DebuggerBrowsable] attribute; I found a minimal case in VisualStudio 2017 15.5 and posted it here.

In this particular case, the expression evaluator (EE) crash appears related to the [DebuggerBrowsable] attribute applied to a property overriding a field of the same name. This will account for some percentage of the cases that people are experiencing out there, but there’s no way of knowing how many are due to this specific issue until it gets fixed.

The full and complete demonstration example is shown in the image (and included below for good measure)

enter image description here

Machine-readable copy of the code in the image:

using System;
using System.Diagnostics;

class Program { static void Main() => new _derived(); }

abstract class _base
{
    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Object trace;
};

class _derived : _base
{
    public _derived() => Debugger.Break();      // <-- vs2017 EE crash when stopped here

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    new public Object trace => base.trace;
}

answered Feb 9, 2018 at 3:36

Glenn Slayden's user avatar

Glenn SlaydenGlenn Slayden

16.9k3 gold badges109 silver badges106 bronze badges

In my case, I had 2 same dll files in 2 different folders (seems, one dll was not correct). Deleting the .dll and rebuilding solution solved my issue.

answered May 15, 2018 at 10:51

constructor's user avatar

constructorconstructor

1,4031 gold badge16 silver badges34 bronze badges

In my case the data I was attempting to inspect was extremely large, a string which unexpectantly had hundreds of megabytes of data in it. The issue wasn’t apparent when the amount of data being inspected was reasonable.

answered Apr 20, 2022 at 8:04

Mick's user avatar

MickMick

6,3894 gold badges48 silver badges67 bronze badges

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!

meJustAndrew's user avatar

meJustAndrew

5,6677 gold badges53 silver badges71 bronze badges

asked Dec 31, 2015 at 10:55

Mehran Khazaeizadeh's user avatar

5

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.

answered Dec 31, 2015 at 18:50

Patrick Nelson - MSFT's user avatar

9

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.

StayOnTarget's user avatar

StayOnTarget

11k10 gold badges49 silver badges75 bronze badges

answered Aug 19, 2016 at 10:12

Lorenz Lo Sauer's user avatar

Lorenz Lo SauerLorenz Lo Sauer

23.1k15 gold badges84 silver badges87 bronze badges

2

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

answered May 13, 2021 at 22:01

neoscribe's user avatar

1

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

answered Nov 28, 2016 at 21:05

Talha Anwer's user avatar

I resolved this issue by simply resetting my visual studio settings by going to: to Tools->Import and Export Settings and selecting to reset to default settings

answered Apr 11, 2018 at 12:58

Brandon's user avatar

I had the same issue with VS2019. I ended up deleting my Documents/Visual Studio 2019 folder. Hope this might help someone, one day. Cost me a day.

PS. Probably not required to delete all, and of course not your projects (if they’re in there), but in my case, everything in there was autogenerated by VS.

I of course tried all solutions mentioned here, and even reinstalling VS didn’t work. Refactoring the class to another name was the ‘trigger’ which made me think there must be some cache, despite cleaning symbols and such didnt work.

answered Dec 17, 2020 at 11:10

Honnes's user avatar

HonnesHonnes

3251 silver badge12 bronze badges

3

In my case I was trying to evaluate lambda expression on List<> and had such error («Internal error in the expression evaluator»). I was using VS2015, so lambda expressions were allowed. It turns out expression evaluator was lacking of Linq library. I added

using System.Linq;

to my current class and voilà! Lambda evaluated.

answered Nov 9, 2016 at 14:03

pilak's user avatar

pilakpilak

413 bronze badges

I encountered the «internal error in the expression evaluator» error when I was debugging in release mode instead of in debug mode. I had changed it to Release when publishing to production and forgot to change it back to Debug.

Release Mode

Debug Mode

answered Nov 18, 2016 at 18:52

MsTapp's user avatar

MsTappMsTapp

4491 gold badge10 silver badges17 bronze badges

Check your use of the [DebuggerBrowsable] attribute; I found a minimal case in VisualStudio 2017 15.5 and posted it here.

In this particular case, the expression evaluator (EE) crash appears related to the [DebuggerBrowsable] attribute applied to a property overriding a field of the same name. This will account for some percentage of the cases that people are experiencing out there, but there’s no way of knowing how many are due to this specific issue until it gets fixed.

The full and complete demonstration example is shown in the image (and included below for good measure)

enter image description here

Machine-readable copy of the code in the image:

using System;
using System.Diagnostics;

class Program { static void Main() => new _derived(); }

abstract class _base
{
    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Object trace;
};

class _derived : _base
{
    public _derived() => Debugger.Break();      // <-- vs2017 EE crash when stopped here

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    new public Object trace => base.trace;
}

answered Feb 9, 2018 at 3:36

Glenn Slayden's user avatar

Glenn SlaydenGlenn Slayden

16.9k3 gold badges109 silver badges106 bronze badges

In my case, I had 2 same dll files in 2 different folders (seems, one dll was not correct). Deleting the .dll and rebuilding solution solved my issue.

answered May 15, 2018 at 10:51

constructor's user avatar

constructorconstructor

1,4031 gold badge16 silver badges34 bronze badges

In my case the data I was attempting to inspect was extremely large, a string which unexpectantly had hundreds of megabytes of data in it. The issue wasn’t apparent when the amount of data being inspected was reasonable.

answered Apr 20, 2022 at 8:04

Mick's user avatar

MickMick

6,3894 gold badges48 silver badges67 bronze badges

October 24, 2021

[Solved] Internal error evaluating expression C#

internal error evaluating expression

A quick fix on the Internal error evaluating expression this article describes a step-by-step guide with an image.   

In this article, I cover the root cause of «Internal error evaluating the expression«. If you are new to IDE Visual Studio either 2015, 2017, or 2019 the show stopper while development is unavoidable.

Let’s get started !

  • How did I encounter this error?
  • This is how I solved it
  • Summary

How did I encounter this error?

To highlight the story behind this,

The requirement is to create a COM object that interacts with the FoxPro application that can not support advanced services in today’s needs.  So the limited services provided  by the FoxPro extends the support  COM Application  that is developed in  DotNET Framework 4.5  

With the above requirement, I initiate development stages;

The next step is to choose IDE for developing COM applications which is a Class Library in  Visual Studio 2019   installed a VS 2019 successfully.  Most of the default settings are pre-defined by the Microsoft VS installer.  

I created a new class library and set the framework version to  DotNET Framework 4.5 

Started coding, where I created a dictionary collection to add decimal key-value pair, the key-value pair has been initialized with values.

Now try to run the application,  The real challenge comes here as the below image underlined the warning message.

Internal Error Evaluating an expression

Internal error evaluating expression

What happened to the values I initialized?  something went wrong or lost the values?

How come my compiler did not prompt before running the application?

This is how it is resolved

With all the questions asked,  it is that some of the legacy default settings were not enabled for Visual Studio 2019 after you installed it. 

Go to Visual Studio 2019  Tools Menu Options  and tick the legacy section settings   Enable fast express evaluation (Managed Only) 

Visual Studio 2019 Options

Save the settings, Compile the program and build it.

This is how I ensured the result is correct,  the same dictionary collection has values in it.

solved - Internal error evaluating expression

This brought me a smile rest of the day.

Summary

Понравилась статья? Поделить с друзьями:
  • Internal error in nvidia ai denoiser 3d max
  • Internal error in install proxy 2 как исправить
  • Internal error illegalresolution samsung 3200
  • Internal error illegalmediasize samsung
  • Internal error gameloop standoff