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开发者_如何学C 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?
Change all options on Debug > Exceptions to "Thrown" That's how the old VS behaved.
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.
Try System.UnauthorizedAccessException. That catches my cross threading errors
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:
System.InvalidOperationException: 'Cross-thread operation not valid: Control 'XXXX' accessed from a thread other than the thread it was created on.'
I imagine there could be a variety of operations that are considered "cross thread" errors so it could fall under different exception categories.
精彩评论