繁体   English   中英

防止控制台应用程序 (.NET Core) 打印“exited with code 0”。 在 VS2019 中

[英]Prevent a Console App (.NET Core) from printing “exited with code 0.” in VS2019

当我在 Visual Studio Community 2019(版本 16.3.1)中使用 Ctrl+F5(无调试启动)启动控制台应用程序(.NET Core)时,最后在控制台 window 中附加以下消息:

C:\HelloWorld\bin\Debug\netcoreapp3.0\HelloWorld.exe(进程 1672)以代码 0 退出。

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

控制台输出

有什么方法可以阻止 Visual Studio 2019 打印此消息? I tried the solution from preventing a similar message from appearing in the Output Window , by changing the option: Tools > Options > Debugging > Output Window > Process Exit Messages = Off, but it has no effect in the Console Window.

Visual Studio 选项

注意:此消息未在 Visual Studio 2017 中显示。它仅在 Visual Studio 2019 中显示,并且仅在 .NET Core 应用程序中显示。

您可以通过检查Tools > Options > Debugging > General > Automatically close the console when debugging stops来禁用它:

Visual Studio 2019 选项

如控制台本身所述(Visual Studio 2019 v16.3.2):

控制台应用

这将使控制台只打印Press any key to continue...通过不调试( CTRL + F5 )而不是退出代码(仍然保持控制台打开)开始:

没有退出代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM