S
Stephen Walch
I am attempting to add a "console mode" to my Winforms app. My intention is
that when I start the app with a special switch (for example "myapp.exe
/batch") to does not launch a graphical UI but instead just displays console
messages.
My first guess was to simply change the Main method of the startup class to
do something like this...
if (batchMode)
{
Console.WriteLine("Now in batch mode");
...
}
else
{
MainForm.Run(); // Launch graphical user interface
}
Unfortunately, it looks like my app does not behave like a real console mode
app in either case. When I execute the app from the command line, the app
returns immediately and text output by Console.Write() does not appear
anywhere.
Setting the app as a Console mode application does not give me what I want
either. With this mode, a big black console output box appears even when in
"GUI mode".
Is there a way to build one executable that supports both modes and
dynamically switches at runtime?
that when I start the app with a special switch (for example "myapp.exe
/batch") to does not launch a graphical UI but instead just displays console
messages.
My first guess was to simply change the Main method of the startup class to
do something like this...
if (batchMode)
{
Console.WriteLine("Now in batch mode");
...
}
else
{
MainForm.Run(); // Launch graphical user interface
}
Unfortunately, it looks like my app does not behave like a real console mode
app in either case. When I execute the app from the command line, the app
returns immediately and text output by Console.Write() does not appear
anywhere.
Setting the app as a Console mode application does not give me what I want
either. With this mode, a big black console output box appears even when in
"GUI mode".
Is there a way to build one executable that supports both modes and
dynamically switches at runtime?