Is there a way to launch a C# application with the following features?
- It determines by command-line parameters whether it is a windowed or console app
- It doesn't show a console when it is asked to be windowed and doesn't show a GUI window when it is running from the console.
For example,
myapp.exe /help
would output to stdout on the console you used, but
myapp.exe
by itself would launch my Winforms or WPF user interface.
The best answers I know of so far involve having two separate exe and use IPC, but that feels really hacky.
What options do I have and trade-offs can I make to get the behavior described in the example above? I'm open to ideas that are Winform-specific or WPF-specific, too.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…