.net 在 C# 控制台应用程序中隐藏控制台窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3853629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:47:17  来源:igfitidea点击:

Hide Console Window in C# Console Application

.netconsole-application

提问by SOF User

The thing is, i really dont want the console window to show up...but the solution should be running. My point here is, I want to keep the application running in the background, without any window coming up.

问题是,我真的不希望控制台窗口出现......但解决方案应该正在运行。我的意思是,我想让应用程序在后台运行,而不会出现任何窗口。

回答by Dirk Vollmar

Change the output type from Console Applicationto Windows Application. This can be done under Project -> Properties -> Applicationin Visual Studio:

将输出类型从Console Application更改为Windows Application。这可以在 Visual Studio 中的Project -> Properties -> Application下完成:

alt text

替代文字

回答by Sekhat

Change your application type to a windows application. Your code will still run, but it will have no console window, nor standard windows window unless you create one.

将您的应用程序类型更改为 Windows 应用程序。您的代码仍会运行,但除非您创建,否则它将没有控制台窗口或标准窗口窗口。

回答by khaja kamal

Instead of Console.Readline/keyyou can use new ManualResetEvent(false).WaitOne()at last. This works well for me.

而不是Console.Readline/keynew ManualResetEvent(false).WaitOne()最后可以使用。这对我很有效。

回答by bla

Maybe you want to try creating a Windows Service application. It will be running in the background, without any UI.

也许您想尝试创建一个 Windows 服务应用程序。它将在后台运行,没有任何 UI。

回答by N T

Change the output type from Console Applicationto Windows Application,

将输出类型从Console Application更改为Windows Application

And Instead of Console.Readline/keyyou can use new ManualResetEvent(false).WaitOne()at the end to keep the app running.

而不是Console.Readline/key你可以new ManualResetEvent(false).WaitOne()在最后使用来保持应用程序运行。