When attempting to call a single-threaded apartment (STA) function from the "wrong" thread (e.g., Clipboard::SetContent(...)
), I see the following message:
Activating a single-threaded class from MTA is not supported.
It's not obvious which functions are STA, so it just seems to jump out from seemingly innocent-looking functions. I couldn't find a simple answer that explains the steps to fix it. The Windows COM documentation is difficult to follow.
How can I reliably identify what is a STA function in order to prevent this error? Isn't there a simple fix?