I've got a C++ gui project exhibiting some strange behavior. On my machine, the code compiles and runs just fine. However, on another machine, The code compiles but ends up running in MTA somehow. Obviously, being in MTA causes all sorts of runtime problems for the GUI. Here is my main:
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
return 0;
}
I can put a breakpoint on the first line of main to check the apartment state, and on the machines that build/execute correctly, it will be "STA", as expected. However, on the problematic machines, it will be "MTA". I can even try switching the apartment mode to STA, without effect.
I've tried removing the debug/release dirs and cleaning the project before compiling, running without a debugger attached, all to no avail. I can't determine any pattern to which machines work and which do not. If I compile the exe on a working machine and bring it over to a problematic machine, it will execute correctly, so I suspect this is somehow a build environment issue. All machines involved are running windows XP with visual studio 2008 standard. Any ideas?