G
Guest
VS 2005 / C++ / __gc program (converted from VS 2003)
i have this code in my program:
int found;
String *temp;
this->ofdOpen->ShowDialog();
the last line produces the folloing unhandleld exeption:
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.
However my Main funtion lookes like this:
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR
lpCmdLine, int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new fclMain());
return 0;
}
Can anybody explain to me whats wrong?
i have this code in my program:
int found;
String *temp;
this->ofdOpen->ShowDialog();
the last line produces the folloing unhandleld exeption:
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.
However my Main funtion lookes like this:
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR
lpCmdLine, int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new fclMain());
return 0;
}
Can anybody explain to me whats wrong?