STAThreadAttribute problem in MC++

kkirtac

Member
Joined
Apr 25, 2006
Messages
13
hi, i m developing a windows forms application using MC++, when i do debug the project , it fails in the line of openFileDialog1->ShowDialog(); and gives an error like that :
An unhandled exception of type System.Threading.ThreadStateException occurred in System.Windows.Forms.dll

Additional information: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.

But its already done in Form1.cpp like that :
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;

i mean the current apartmentstate is already set as STA... i cant debug the project cos of that error...
 
well, i added [STAThreadAttribute] just above the main function and it did solve the problem..good luck
 
Back
Top