评估需要一个线程来临时运行。使用观察窗口执行评估
我完全陷入困境。我正在测试 MetaTrader API 并在尝试在 VS 2010 的立即窗口中运行方法时出现下一个错误:
mscorlib.dll 中发生了“System.Threading.ThreadAbortException”类型的第一次机会异常
System.Runtime.Remoting.dll 中发生了“System.Threading.ThreadAbortException”类型的第一次机会异常
评估需要一个线程来临时运行。使用“观察”窗口执行评估。
这是什么意思?会因为运行时版本差异(api 2.0、app 4.0)而发生这种情况吗?
I'm completely stuck. I'm testing MetaTrader API and getting next error when tries to run a method in the Immediate Window of 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.
What does it mean? Can it happens because of runtime versions difference (api 2.0, app 4.0)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我相信您通过立即窗口调用的方法最终会调用 调试器.NotifyOfCrossThreadDependency。此方法仅在 .NET 4.0 中引入,因此使用旧版本的运行时时该问题不会自行重现,这是有道理的。 这篇博文详细解释了
NotifyOfCrossThreadDependency
,但其要点是它会导致 Watch 窗口显示一个 Refresh 按钮,必须在评估发生之前按下该按钮。但是,如果通过立即窗口对其进行评估,则会出现“评估需要临时运行线程。请使用监视窗口执行评估”错误。以下是重现此错误的示例属性:
I believe the method you are calling through the Immediate Window ends up calling Debugger.NotifyOfCrossThreadDependency. This method was only introduced in .NET 4.0, so it makes sense that the problem won't reproduce itself when using an older version of the runtime. This blog post explains
NotifyOfCrossThreadDependency
in detail, but the gist of it is that it causes the Watch window to show a Refresh button which must be pressed before the evaluation occurs. If it is evaluated through the Immediate Window, though, you get the "Evaluation requires a thread to run temporarily. Use the Watch window to perform the evaluation" error.Here's an example property that reproduces this error:
我相信该错误意味着您尝试执行的方法正在生成一个线程。但是,由于程序处于中断模式,因此无法运行。为了避免死锁(该方法将永远等待无法运行的线程),Visual Studio 会终止所有生成的线程。
我的建议是将调用移至程序中,并使用其他方式来执行它。
I believe that error means that the method you are trying to execute is spawning a thread. However, since the program is in Break mode, it can't run. To avoid a deadlock (where the method will wait forever for a thread that won't run), Visual Studio kills any spawned threads.
My suggestion is to move the call into the program, and use some other means to execute it.
这是因为服务器在 .NET 2.0 下运行,而客户端(通过 .NET Remoting)在 .NET 4.0 下运行。
将客户端切换到 .NET 2.0/3.5 解决了该问题。
That's because the server is running under .NET 2.0 and a client (thru .NET Remoting) - under .NET 4.0.
Switching client to .NET 2.0/3.5 fixed the problem.
不要删除 app.config,它将包含如下信息:
do not remove the app.config which will contain information like follows: