tksuoran's picture

SVN: The CLR has been unable to transition...

I got OpenTK from SVN to resolve couple of issues. Now my app starts fine but after maybe 1 minute I get this:

"The CLR has been unable to transition from COM context 0x4b8390 to COM context 0x4b8500 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations."


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Try removing the [STAThread] attribute from your main method.

tksuoran's picture

Thanks, that helped. Any insight why this change was needed?

tksuoran's picture

Thanks, that helped. Any insight why this change was needed?

the Fiddler's picture

Apparently, the managed debug assistant doesn't like the message pump in OpenTK. Messages *are* being pumped (otherwise your application would have locked up) so I am not sure why this is happening. Things appear to work fine when running outside Visual Studio, too.

If someone has any ideas, do tell.

A "short" introduction to the COM appartment model and how it affects the CLR. It's a huge and complicated subject.

Ollhax's picture

In case someone has the same problem but cannot disable STAThread (in my case, I want to use the clipboard), I think I found a better solution. Just enable unmanaged code debugging (in the project settings, debug tab) and it goes away.

I was lead to this from this article:

It is possible for this MDA to be falsely activated when all of the following conditions are met:
... Unmanaged debugging is not enabled.