简体   繁体   English

“表达式计算器中的内部错误”

[英]"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.我在 visual studio 2015 的表达式求值器中遇到了一个问题,上面写着“表达式求值器内部错误”,经过一些调查我发现这是由使用反射加载的程序集引起的。 This assembly wouldn't throw any exceptions but after that, vs exp evaluator will fail.该程序集不会抛出任何异常,但在那之后,vs exp 评估器将失败。 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我所有的项目都使用 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".为了更好的解决方法,不要选中“使用托管兼容模式”,而是选中“使用旧版 C# 和 VB 表达式计算器”。 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 .只是扩展了Patrick Nelson提供的解决方案 For Visual Studio 2015+ as inquired, the steps are as follows.对于查询到的Visual Studio 2015+,步骤如下。

If you're debugging at the moment, this option will be unavailable.如果您此时正在调试,则此选项将不可用。 Stop the debugger.停止调试器。

Go to Tools -> Options转到工具- >选项

VS 选项

and here under the Options select Debug -> General and scroll down to find the ...legacy C# expression.. option:在 Options 下选择Debug -> General并向下滚动找到...legacy C# expression..选项:

VS 选项调试遗留选项

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!我终于弄清楚是什么在我的 Visual Studio 中造成了这个问题!

The quick fix is to delete the debug object favorites from the "Documents/Visual Studio xx/Visualizers" folder and restart Visual Studio.快速修复是从“Documents/Visual Studio xx/Visualizers”文件夹中删除调试对象收藏夹并重新启动 Visual Studio。

在此处输入图像描述 When you "pin" a variable in the debugger, Visual Studio saves a 'favorite' json object for it.当您在调试器中“固定”一个变量时,Visual Studio 会为其保存一个“最喜欢的”json 对象。

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). Visual Studio 中似乎存在一个错误,该错误破坏了一些本质上是动态的子变量的“收藏夹” (虽然不能完全确定条件)。 在此处输入图像描述

For me checking "Use Managed Compatibility Mode" option worked.对我来说,选中“使用托管兼容模式”选项有效。 I was also seeing question marks when hovering over variables, instead of properties and values将鼠标悬停在变量而不是属性和值上时,我也看到了问号

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我通过以下方式简单地重置我的 visual studio 设置解决了这个问题:to Tools->Import and Export Settings 并选择重置为默认设置

I had the same issue with VS2019.我在 VS2019 上遇到了同样的问题。 I ended up deleting my Documents/Visual Studio 2019 folder.我最终删除了我的 Documents/Visual Studio 2019 文件夹。 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.可能不需要删除所有项目,当然也不需要删除您的项目(如果它们在其中),但就我而言,其中的所有内容都是由 VS 自动生成的。

I of course tried all solutions mentioned here, and even reinstalling VS didn't work.我当然尝试了这里提到的所有解决方案,甚至重新安装 VS 也没有用。 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.将类重构为另一个名称是“触发器”,这让我认为必须有一些缓存,尽管清除符号等没有用。

In my case I was trying to evaluate lambda expression on List<> and had such error ("Internal error in the expression evaluator").在我的例子中,我试图在 List<> 上评估 lambda 表达式并出现这样的错误(“表达式评估器中的内部错误”)。 I was using VS2015, so lambda expressions were allowed.我使用的是 VS2015,因此允许使用 lambda 表达式。 It turns out expression evaluator was lacking of Linq library.原来表达式计算器缺少 Linq 库。 I added我加了

using System.Linq;

to my current class and voilà.到我现在的班级,瞧。 Lambda evaluated. Lambda 进行了评估。

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 并忘记将其更改回 Debug。

发布模式

调试模式

Check your use of the [DebuggerBrowsable] attribute;检查您对[DebuggerBrowsable]属性的使用; I found a minimal case in VisualStudio 2017 15.5 and posted it here .我在 VisualStudio 2017 15.5 中找到了一个最小案例并将其发布在此处

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.在这种特殊情况下,表达式求值器 (EE) 崩溃似乎与应用于覆盖同名字段的属性的[DebuggerBrowsable]属性有关。 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)完整和完整的演示示例如图所示(并包含在下面以备不时之需)

在此处输入图像描述

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;
}

In my case, I had 2 same dll files in 2 different folders (seems, one dll was not correct).在我的例子中,我在 2 个不同的文件夹中有 2 个相同的 dll 文件(似乎,一个 dll 不正确)。 Deleting the.dll and rebuilding solution solved my issue.删除.dll 并重建解决方案解决了我的问题。

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.当检查的数据量合理时,问题并不明显。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio立即窗口“表达式计算器中的内部错误” - Visual Studio Immediate window “Internal error in the expression evaluator” 尝试调试 WCF 服务代码 (MSVS 2013) 时,在“添加监视”函数上获取“表达式计算器中的内部错误” - Get "Internal error in the expression evaluator" on "Add watch" function when trying to debug WCF service code (MSVS 2013) 使用Roslyn以编程方式编译代码时,C#在表达式求值器中获取内部错误 - c# getting Internal error in the expression evaluator when programmatically compiling code with Roslyn 远程调试msvsmon.exe VS2015或无法附加到进程时表达式计算器中的内部错误。 rpc服务器不可用 - Internal error in the expression evaluator when remote debugging msvsmon.exe VS2015 or unable to attach to the process. the rpc server is unavailable wp7的表达式评估器? - Expression evaluator for wp7? C#/ Python / Ruby的表达评估器 - Expression evaluator for C#/Python/Ruby 数学表达式求值程序的简单库或实现 - Simple library or implementation for a mathematical expression evaluator Evaluator.PartialEval减少提供的表达式 - Evaluator.PartialEval reduce provided expression 使用C#Expression Evaluator过滤列表 - Use C# Expression Evaluator for filtering a list 将评估器合并成三元表达式是否不好? (C#) - Is it bad to coalesce the evaluator in a ternary expression? (C#)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM