控制台应用程序问题
我想知道为什么当我创建控制台应用程序并将主要方法“转换”为与创建 Windows 窗体项目时自动生成的主要方法相同时,控制台仍然出现在屏幕上:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Windows.Forms;
namespace Chapter16
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new CultureTest());
}
}
}
此代码与 Program.cs 中的代码相同。来自 Windows 窗体应用程序的 cs。 问题是控制台仍然出现在屏幕上,而 Windows 窗体项目中的情况并非如此。 这是为什么?
亲切的问候 PK
I was wandering why when I create console application and 'transform' the main method to look identically with main method auto-generated when creating windows forms project, the console still appears on the screen:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Windows.Forms;
namespace Chapter16
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new CultureTest());
}
}
}
This code is identical with the code located in Program.cs from windows forms application. The problem is that console still appears on the screen which is not the case in windows forms project. Why is that?
Kind Regadrs
PK
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将项目属性中的目标类型设置为“Windows 应用程序”。 这相当于
/target:winexe
编译器开关。 它将更改二进制头中的子系统
,以告诉Windows不要打开shell窗口。You should set the target type in project properties to "Windows Application". This is equivalent to
/target:winexe
compiler switch. It'll alter thesubsystem
in binary header to tell Windows not to open up a shell window.