我编写了一个既可以在命令行上运行,也可以使用WPF UI运行的应用程序。
[STAThread]
static void Main(string[] args)
{
// Does magic parse args and sets IsCommandLine to true if flag is present
ParseArgs(args);
if(IsCommandLine)
{
// Write a bunch of things to the console
}
else
{
var app = new App();
app.Run(new Window());
}
}
我将项目的输出类型设置为Console Application,如果我试图通过双击exe来执行它,我会得到一个弹出的控制台窗口。如果没有设置标志(通过命令args传入),我不想向用户显示控制台窗口。
但是,如果我将项目的输出类型设置为Windows Application,双击行为是正常的,但是当我在控制台中运行它时,我得不到控制台输出(Console.Writeline)
https://stackoverflow.com/questions/5339193
复制相似问题