[英]How to pass output of separate console window to Visual Studio output window?
I'm writing an application in C# that uses an OpenGL binding ( OpenGL.NET ) and a GLFW library binding.我正在 C# 中编写一个应用程序,该应用程序使用 OpenGL 绑定( OpenGL.NET )和 GLFW 库绑定。 When running the application, it shows the black console window and uses this for displaying all console output (the
Console.WriteLine
output appears here).运行应用程序时,它显示黑色控制台 window 并使用它来显示所有控制台 output(
Console.WriteLine
output 出现在这里)。
Nothing shows up in the Visual Studio output window, as it normally would.正常情况下,Visual Studio output window 中没有显示任何内容。 I'm used to view the Visual Studio output window and never used some software that creates its own console / command line for whatever reason.
我习惯于查看 Visual Studio output window 并且从未使用过一些软件来创建自己的控制台/命令行,无论出于何种原因。 Although it is not a big problem, it's irritating that (when debugging) all output in that separate console is lost when I close my application.
虽然这不是一个大问题,但令人恼火的是(在调试时)当我关闭我的应用程序时,那个单独的控制台中的所有 output 都丢失了。
I'm sure this situation has something to do with the software architecture/properties of the included third party software I mentioned.我确信这种情况与我提到的包含的第三方软件的软件架构/属性有关。
My question is: is it possible to somehow pass/copy the console output like Console.WriteLine
that shows up in the separate console, to the output window of Visual Studio?我的问题是:是否有可能以某种方式将控制台 output (例如显示在单独控制台中的
Console.WriteLine
)传递/复制到 Visual Studio 的 output window? And if possible, how to do it?如果可能的话,该怎么做? If possible I prefer not to use a different method or functionality for outputting things to the console.
如果可能的话,我不希望使用不同的方法或功能将内容输出到控制台。 So avoiding to change every line where I use
Console.WriteLine
.所以避免改变我使用
Console.WriteLine
的每一行。
I'm using Visual Studio 2017.我正在使用 Visual Studio 2017。
How to pass output of separate console window to Visual Studio output window?
如何将单独控制台 window 的 output 传递给 Visual Studio output Z05B8C74CBD96FBF2DE4C1A352702?
You can use Debug.WriteLine()
with using namespace System.Diagnostics
, it will output the info on the output window.您可以将
Debug.WriteLine()
与 using namespace System.Diagnostics
一起使用,它将 output 上的信息 output window 上。
There is no other easy function copying the info from console window into output window directly.没有其他简单的 function 将信息从控制台 window 直接复制到 output Z05B8C742CBD96FBF2DEZC1A34F 中。 Only manually use
Debug.Writeline()
to add any information you want.只能手动使用
Debug.Writeline()
添加您想要的任何信息。
Note : You should use Start Debugging under Debug menu rather than Start without Debugging and then you will see them on the output window .注意:您应该使用Debug菜单下的Start Debugging而不是Start without Debugging ,然后您将在output window上看到它们。
2) Besides , if you use Release configuration or use other configurations that are not Debug to run your project, Debug.writeline()
will not work. 2)此外,如果你使用Release配置或使用其他非Debug配置来运行你的项目,
Debug.writeline()
将不起作用。
Instead , you should use相反,您应该使用
Trace.WriteLine();
Also , it can be used in the Debug configuration.此外,它可以在调试配置中使用。
In other words , it is better to use it.换句话说,最好使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.