Mixing ActiveX GUI C++ and .NET

I came across a problem the other day. I have:
  • An ActiveX GUI control that requires a single-threaded apartment model in C++ (MFC)
  • A C++ static library that is a bridge between C++ and a .NET class library
  • A .NET class library
The GUI control cannot be instantiated in C++. Why? The .NET thread apartment model is multi-threaded by default. How do I set the apartment model of the C++ program to be STA, when there is no .NET code directly in the C++ program? Add a linker option to the project: /CLRTHREADATTRIBUTE:STA

Comments

Post a Comment

Popular posts from this blog

Gain SSH access to the Buffalo LinkStation 421e

Enable Buffalo LinkStation 421e SFTP

PublicKey attribute in .NET Framework 3.5 SP1 Does not match that of file...