Release Build problem with System::Console::WriteLine()

Release Build problem with System::Console::WriteLine()

Post by bW9ycGgzMj » Fri, 26 Aug 2005 01:31:04


I have a problem in calling System::Console::WriteLine() from a Release Build
in Visual Studio .NET 2003 that I can't figure out.

It is reproducable with a simple Windows Forms app that is compiled using
/subsystem:windows, and thus does not have a natural console.

In Form1.cpp, between

System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new Form1());


Create a new console using

AllocConsole()

which completes without error, and
then i added

System::Console::WriteLine("Hello, World!");


If you build this in Debug Mode and start this executable via the de ***
(F5) or via Explorer, then the text is output to the Console.

If you build in Release Mode, and start the executable via the de *** , the
text is again correctly output to the Console.

if you run the Release Mode binary from Windows Explorer, the console is
created (no errors returned by AllocConsole()) but nothing is printed! Nada!

It doesn't seem to be related to buffering, because calling Flush

System::Console::OpenStandardOutput()->Flush();

doesn't help. I'm not interested in work arounds per se, (i.e. I have one
already), but would like to know if I'm driving the framework incorrectly.