直接陷进去,一个非常基本的例子:
using System;
using System.Windows.Forms;
class test
{
static void Main()
{
Console.WriteLine("test");
MessageBox.Show("test");
}
}
如果我使用默认选项(在命令行中使用 csc)编译它,正如预期的那样,它将被编译成一个控制台应用。另外,因为我导入了 System.Windows.Forms
,它还将显示一个消息框。
现在,如果我使用选项 /target:winexe
(我认为这与从项目选项中选择 Windows Application
是相同的) ,正如预期的那样,我将只看到 Message Box,没有控制台输出。
(事实上,从命令行启动它的那一刻起,我就可以在应用程序完成之前发出下一个命令)。
因此,我的问题是——我知道你可以从一个控制台应用输出“ Windows”/form,但是有没有办法显示一个 Windows 应用程序的控制台呢?