C# 如何在 Visual Studio 输出窗口中运行控制台应用程序,而不是打开新的命令提示符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/194436/
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
How do you run a console application in the Visual Studio output window, instead of opening a new command prompt?
提问by yood.mp
I'm developing a simple console application in Visual Studio 2008 and want to run it in the output window inside Visual Studio 2008, instead of having a separate command prompt window come up. Is there a way to do this?
我正在 Visual Studio 2008 中开发一个简单的控制台应用程序,并希望在 Visual Studio 2008 内的输出窗口中运行它,而不是出现单独的命令提示符窗口。有没有办法做到这一点?
回答by Andrew
The only way I know of is to add it as an external tool and tick the Use output windowcheckbox when you define the tool.
我所知道的唯一方法是将其添加为外部工具,并在定义工具时勾选使用输出窗口复选框。
回答by Jon Skeet
Does it actually have to be a console application? If you make it a WinForms app (even though it doesn't create any GUI elements) you'll get the console output in the Output window. However, you then can't read from console input, and obviously you won't get any output at all if you run from a real command line or in explorer. For simple test applications this may be fine, of course!
它真的必须是一个控制台应用程序吗?如果您将其设为 WinForms 应用程序(即使它不创建任何 GUI 元素),您将在“输出”窗口中获得控制台输出。但是,您将无法从控制台输入中读取数据,而且如果您从真正的命令行或资源管理器中运行,显然您根本不会得到任何输出。当然,对于简单的测试应用程序,这可能没问题!
回答by Harald Scheirich
If you run the console app in the post build step it's output will go to the output window. The inability to do this easily has been on of my biggest peeves with VS (any version)
如果您在后期构建步骤中运行控制台应用程序,它的输出将转到输出窗口。无法轻松做到这一点一直是我对 VS(任何版本)最大的不满
回答by Gammerz
ctrl+F5 seems to "start without debugging" in the debugging menu.
ctrl+F5 似乎在调试菜单中“启动而不调试”。
回答by cimnine
It is a fairly old question, but as there is no answer marked as solution yet, try the answer given over here: Having the output of a console application in Visual Studio instead of the console
这是一个相当古老的问题,但由于还没有标记为解决方案的答案,请尝试此处给出的答案:在 Visual Studio 中而不是控制台中输出控制台应用程序