Visual Studio 2017 Debug Error: To prevent an unsafe abort when evaluating the function *.toString all threads were allowed to run

Visual Studio 2017 Debug Error: To prevent an unsafe abort when evaluating the function *.toString all threads were allowed to run

我将 Visual Studio 2017 更新到版本 15.8.2。

这次更新后,我在调试时开始遇到这些错误:

错误信息如下:

Visual Studio Debug Error: To prevent an unsafe abort when evaluating the function *.toString all threads were allowed to run. This may have changed the state of the process and any breakpoints encountered have been skipped.

这个错误经常出现,一段时间后 Visual Studio 崩溃。

我尝试再次卸载并安装 Visual Studio 并重置首选项,但我没有成功。

当我禁用选项:“启用 属性 求值和其他隐式函数调用”时,当我尝试通过将鼠标移到某些属性上来求值时,我会遇到同样的错误。没有它很难调试,而且我在这个构建之前没有问题。

问题与 C#Visual Basic (.NET).

相同

这个问题有解决办法吗?我的团队使用 Visual Studio 2017 版本 15.7.4

处理同一个项目没有问题

Visual Studio 2017 Debug Error: To prevent an unsafe abort when evaluating the function *.toString all threads where allowed to run

根据this document

One common reason for this problem is that when the debugger evaluates a property, it only allows the thread being inspected to execute. So if the property is waiting on other threads to run inside the debugged application, and if it is waiting in a way that the .NET Runtime isn't able to interrupt, this problem will happen.

要解决此问题,您可以尝试以下两种可能的解决方案:

  • 解决方案 #1:防止调试器调用 getter 属性 或
  • 解决方案 #2:让目标代码要求调试器中止 评估 ToString 方法

此外,如果上述方法无法解决该错误,您还可以安装以前的旧版本 Visual Studio 以检查它是否适合您:

https://docs.microsoft.com/en-us/visualstudio/productinfo/installing-an-earlier-release-of-vs2017#top

希望这对您有所帮助。

我添加了相同的错误消息,但使用了不同的函数名称:

To prevent an unsafe abort when evaluating the function 'Microsoft.VisualStudio.Debugger.Runtime.Tracing.Refresh' all threads were allowed to run. This may have changed the state of the process and any breakpoints encountered have been skipped.


这就是我摆脱这个讨厌的错误的方法:
在 Visual Studio 2017 年前往
工具 → 选项 → 调试 → 常规 → 检查 'Use Managed Compatibility Mode'
感谢这篇文章:
https://www.codeart.dk/blog/2018/9/vs2017-debugger-timeout/