System.Threading.ThreadStateException

  • Thread starter Thread starter Bumbrlik
  • Start date Start date
B

Bumbrlik

I have a form with a grid. When a user selects some text
in the Grid and presses Ctrl-C to
copy the text, .NET throws an Exception with the
description:

"The current thread must set to Single Thread Apartment
(STA) mode before
OLE calls can be made. Ensure that your Main function has
STAThreadAttribute marked on it."

However, I already have
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;

in my _tWinMain.

Thanks for any suggestions,
Bumbrlik
 
Bumbrlik said:
However, I already have
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;

This value must be specified as an attribute or as the
very first thing when a thread is created. Changing this
value later has no effect. Look up STAThreadAttribute.
 
Back
Top