如何中断无效的跨线程错误
我们最近刚刚从 VS2005 升级到 VS2010。我注意到,与 VS2005 不同,当调试代码并且 VS2010 IDE 遇到“无效跨线程”操作时,IDE 只是终止应用程序,而不会“破坏”导致问题的代码行。
我查看了“调试”> IDE 的异常部分,但我没有在 System.Threading 命名空间下找到“无效的跨线程操作”作为有效选项。我有点不知道如何让 VS2010 IDE 表现得像 VS2005 IDE,它会破坏代码并突出显示导致无效跨线程操作的行。
有人可以帮我吗?
We just recently upgraded from VS2005 to VS2010. I've noticed that unlike VS2005, when debugging code and the VS2010 IDE encounters an "Invalid Cross Thread" operation, the IDE simply terminates the application without "breaking" on the line of code that is causing the problem.
I looked into the Debug > Exceptions section of the IDE, but I didn't find "Invalid Cross Thread Operation" as a valid option under the System.Threading namespace. I am kinda lost at how to get the VS2010 IDE to behave like the VS2005 IDE, where it would break code and highlight the line causing an invalid cross-thread operation.
Can anyone help me out here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
更改“调试”>“所有选项” “抛出”的例外情况
老VS就是这样的。
Change all options on Debug > Exceptions to "Thrown"
That's how the old VS behaved.
我发现,如果我打开所有 System.Threading 异常(即使未列出跨线程),IDE 现在确实会因跨线程错误而中断。我不知道“哪个”线程异常命名空间拥有这个特定的选项,但是,现在我的 IDE 像 VS2005 一样工作。
I found that if I turn on all the System.Threading exceptions (even though Cross-Thread is not listed), the IDE now does break on Cross-Thread errors. I have no clue "which" Threading Exception Namespace holds this particular option, but, now I have my IDE working like VS2005 did.
尝试 System.UnauthorizedAccessException。这捕获了我的交叉线程错误
Try System.UnauthorizedAccessException. That catches my cross threading errors
这是一个旧线程,但对于 Visual Studio 2017,我通常会在 System.InvalidOperationException 下收到跨线程操作异常。
异常的文本是:
我想可能有多种操作被视为“跨线程”错误,因此它可能属于不同的异常类别。
This is an old thread, but for Visual Studio 2017, I will typically get a cross-thread operation exception under System.InvalidOperationException.
The text for the exception is:
I imagine there could be a variety of operations that are considered "cross thread" errors so it could fall under different exception categories.