Visual Studio 2019:出现错误弹窗:"To prevent an unsafe abort when evaluating the function..."

Visual Studio 2019: Error pop-up appears: "To prevent an unsafe abort when evaluating the function..."

我在启动 ASP.NET Core 3 WebApi 项目时遇到 Visual Studio 2019(版本 16.3.8)的问题。

单击确定后 项目启动并运行,没有任何问题。然而,每次我开始我的解决方案时,弹出窗口都会让我烦恼。

  1. 如何停止显示?
  2. 它到底想告诉我什么?

似乎有两种可能的解决方案,至少对 Visual Studio 2019 年的我有用。

解决方案

转到Tools => Options => Debugging => General然后启用Use Managed Compatibility Mode(感谢Nan Yu)或禁用Enable property evaluation and other implicit function calls

第二种解决方案面临的缺点是,当处于中断模式时,我们必须手动点击局部刷新 window 才能看到变量内容。

背景

消息告诉我们,由于隐式 属性 评估,我们的系统状态在处于中断模式时可能会发生变化。

By default, we tell Visual Studio debugger to try and evaluate properties implicitly. This of course requires running code while we are braked, and not only display memory content. Running code, might potentially change the state of the system, which is not always what we want. For example, I might be increasing a counter every time the property is accessed, which means that when the debugger will try to evaluate the property, my code will run, the counter will be incremented, and my system state is changed, even though I am braked.

https://blogs.msdn.microsoft.com/eliofek/2012/12/12/why-do-we-get-the-function-evaluation-requires-all-threads-to-run/

我的手表 window 中有一些变量导致出现此错误弹出窗口。只需将它们从您的手表中删除 window,错误弹出窗口就不会再显示了。