System.Threading.ThreadStateException

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
 
?

=?ISO-8859-1?Q?Christian_Fr=F6schlin?=

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top