Having the output of a console application in Visual Studio instead of the console

前端 未结 12 781
醉话见心
醉话见心 2020-11-29 00:06

When doing a console application in Java with Eclipse, I see the output being put in a text box in the IDE itself, instead of having a console popping up like in Visual Stud

相关标签:
12条回答
  • 2020-11-29 00:32

    In the Visual Studio Options Dialog -> Debugging -> Check the "Redirect All Output Window Text to the Immediate Window". Then go to your project settings and change the type from "Console Application" to "Windows Application". At that point Visual Studio does not open up a console window anymore, and the output is redirected to the Output window in Visual Studio. However, you cannot do anything "creative", like requesting key or text input, or clearing the console - you'll get runtime exceptions.

    0 讨论(0)
  • 2020-11-29 00:37

    regarding System.Diagnostics.Debug producing a lot of "junk" in the Output window: You can turn that off by right clicking in the output window. E.g. there's an item "Module Load Messages" which you want to disable and an item "Program Output" which you want to keep.

    0 讨论(0)
  • 2020-11-29 00:40

    Use System.Diagnostics.Trace

    Depending on what listeners you attach, trace output can go to the debug window, the console, a file, database, or all at once. The possibilities are literally endless, as implementing your own TraceListener is extremely simple.

    0 讨论(0)
  • 2020-11-29 00:46

    Step 1: Right click on the Project Name in Solution Explorer then make the Output type as Window Application

    Step 2: Debug-->Options..-->Debugging (Expand)-->General-->Redirect All Output Window Text to the Immediate Window

    0 讨论(0)
  • 2020-11-29 00:47

    In the Tools -> Visual Studio Options Dialog -> Debugging -> Check the "Redirect All Output Window Text to the Immediate Window".

    0 讨论(0)
  • 2020-11-29 00:49

    If you need output from Console.WriteLine, and the Redirect All Output Window Text to the Immediate Window does not function and you need to know the output of Tests from the Integrated Test Explorer, using NUnit.Framework our problem is already solved at VS 2017:

    Example taken from C# In Depth by Jon Skeet: This produce this output at Text Explorer:

    When we click on Blue Output, under Elapsed Time, at right, and it produces this:

    Standard Output is our desired Output, produced by Console.WriteLine.

    It functions for Console and for Windows Form Applications at VS 2017, but only for Output generated for Test Explorer at Debug or Run; anyway, this is my main need of Console.WriteLine output.

    0 讨论(0)
提交回复
热议问题