MC++ FAQ
Monday 07 | 15 | 2002
STAThread Attribute
If you're applying the STAThread attribute to your MC++ application's entry point, it will not work.

You're probably doing something like this:

[STAThread]
int main(void)
{
   // code here
}

The problem is that main() (or WinMain()) are not the actual executable entry points. That role is taken in MC++ applications by the CRT, via the _mainCRTStartup() (or _WinMainCRTStartup()) function.

There are two ways of getting around this:

  1. If you don't use the CRT, bypass it's initialization code and use the /entry: linker option to make your own function the real entrypoint in the exe. This probably won't be a viable option for most people using MC++, though.
  2. Set it directly from the code:
    Thread::CurrentThread->ApartmentState = ApartmentState::STA;
    
Posted by tomasr at July 15, 2002 04:36 AM
Comments

I try to set it programmatically, but it doesn't change. Any ideas why?

VS.NET 2003

Posted by: Jeff Lewis on April 18, 2003 08:44 PM

I have same problem. It does not change.

Posted by: Shuming on May 1, 2003 10:07 PM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?

Copyright(C) 2002, Tomas Restrepo, All rights reserved. Powered by Movable Type 2.63