gpt4 book ai didi

c# - 评估需要一个线程临时运行。使用 Watch 窗口执行评估

转载 作者:可可西里 更新时间:2023-11-01 08:43:55 43 4
gpt4 key购买 nike

我是 completely stuck .我正在测试 MetaTrader API并在 VS 2010 的即时窗口中尝试运行方法时出现下一个错误:

A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll

A first chance exception of type 'System.Threading.ThreadAbortException' occurred in System.Runtime.Remoting.dll

Evaluation requires a thread to run temporarily. Use the Watch window to perform the evaluation.

这是什么意思?是否会因为运行时版本差异(api 2.0,app 4.0)而发生?

最佳答案

我相信您通过立即窗口调用的方法最终会调用 Debugger.NotifyOfCrossThreadDependency .此方法仅在 .NET 4.0 中引入,因此使用较旧版本的运行时时问题不会自行重现是有道理的。 This blog post详细解释了 NotifyOfCrossThreadDependency,但其要点是它会导致 Watch 窗口显示一个刷新按钮,必须在计算发生之前按下该按钮。但是,如果通过立即窗口对其进行评估,您会收到“评估需要临时运行的线程。使用监 window 口执行评估”错误。

这是一个重现此错误的示例属性:

    public int CauseError
{
get
{
Debugger.NotifyOfCrossThreadDependency();
return 5;
}
}

关于c# - 评估需要一个线程临时运行。使用 Watch 窗口执行评估,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4280604/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com