Article | 41023835 |
Type | HowTo |
Product | Engine |
Version | 5.0.1.1035 |
Date Added | 1/18/2005 |
Submitted by | Massimo Schinardi |
Keywords |
An unhandled exception of type 'System.Threading.ThreadStateException' occurred in system.windows.forms.dll
Additional information: Could not instantiate ActiveX control 'd4739fdd-dc16-4ab8-bb0a-469661ccae31' because the current thread is not in a single-threaded apartment.
In the file form1.cpp where is the main form replace the:
//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;
//}
with:
using
namespace System::Threading;public
__gc class ThreadWorkint
APIENTRY _tWinMain(HINSTANCE hInstance,