G
Guest
As a newcomer to C++ i .NET I've come across the following problem:
- When trying to establish drag&drop from one form to another I get a
runtime exception when the drop form is created:
(translated from swedish...)
System.InvalidOperationException: DragDrop-registration failed. --->
System.Threading.ThreadStateException: The current thread must have STA-state
(Single Thread Apartment) before OLE-calls can be made. Check that the main
function has the STAThreadAttribute declared.
As far as I can see this is already a fact:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new Form1());
return 0;
}
I've tried to make the same statement in the form's constructor without
success.
I am using Visual Studio .NET 2003 .
Has anybody solved this?
- When trying to establish drag&drop from one form to another I get a
runtime exception when the drop form is created:
(translated from swedish...)
System.InvalidOperationException: DragDrop-registration failed. --->
System.Threading.ThreadStateException: The current thread must have STA-state
(Single Thread Apartment) before OLE-calls can be made. Check that the main
function has the STAThreadAttribute declared.
As far as I can see this is already a fact:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new Form1());
return 0;
}
I've tried to make the same statement in the form's constructor without
success.
I am using Visual Studio .NET 2003 .
Has anybody solved this?