简体   繁体   中英

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. When running the application, it shows the black console window and uses this for displaying all console output (the Console.WriteLine output appears here).

Nothing shows up in the Visual Studio output window, as it normally would. 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. 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.

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? 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 .

I'm using Visual Studio 2017.

How to pass output of separate console window to Visual Studio output window?

You can use Debug.WriteLine() with using namespace System.Diagnostics , it will output the info on the output window.

There is no other easy function copying the info from console window into output window directly. Only manually use Debug.Writeline() to add any information you want.

Note : You should use Start Debugging under Debug menu rather than Start without Debugging and then you will see them on the 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.

Instead , you should use

 Trace.WriteLine();

Also , it can be used in the Debug configuration.

In other words , it is better to use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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