控制台应用程序问题

发布于 2024-07-17 12:58:42 字数 686 浏览 2 评论 0原文

我想知道为什么当我创建控制台应用程序并将主要方法“转换”为与创建 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一桥轻雨一伞开 2024-07-24 12:58:42

您应该将项目属性中的目标类型设置为“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 the subsystem in binary header to tell Windows not to open up a shell window.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文