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
It's time to check the latest release/s for Visual Studio, folks. The most suggested solution that did not work for some of you before might work now.
In Visual Studio 2017 (Release Version 15.4.2 and above), going to Tools > Options > Debugging > General > (Check Box) Redirect all Output Window text to Immediate Window
has worked for me.
Few Notes: 1. To see the Immediate Window, make sure that you are in Debugging mode. 2. There should now be 3 other debugging tools available at your disposal, namely, Call Stack, Breakpoints, and Command Window, as shown below:
Best wishes!
You could create a wrapper application that you run instead of directly running your real app. The wrapper application can listen to stdout and redirect everything to Trace. Then change the run settings to launch your wrapper and pass in the path to the real app to run.
You could also have the wrapper auto-attach the debugger to the new process if a debugger is attached to the wrapper.
Instead, you can collect the output in a test result.
You can't supply input, but you can easily provide several tests with different command line arguments, each test collecting the output.
If your goal is debugging, this is a low effort way of offering a repeatable debugging scenario.
namespace Commandline.Test
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class CommandlineTests
{
[TestMethod]
public void RunNoArguments()
{
Commandline.Program.Main(new string[0]);
}
}
}
I know this is just another answer, but I thought I'd write something down for the new Web Developers, who might get confused about the "Change to a Windows Application" part, because I think by default an MVC application in Visual Studio 2013 defaults to an Output Type of Class Library.
My Web Application by default is set as an output type of "Class Library." You don't have to change that. All I had to do was follow the suggestions of going to Tools > Options > Debugging > Redirect all Output Window text to the Immediate Window. I then used the System.Diagnostics.Trace
suggestion by Joel Coehoorn above.
A simple solution that works for me, to work with console ability(ReadKey, String with Format and arg etc) and to see and save the output:
I write TextWriter that write to Console
and to Trace
and replace the Console.Out
with it.
if you use Dialog -> Debugging -> Check the "Redirect All Output Window Text to the Immediate Window" you get it in the Immediate Window and pretty clean.
my code: in start of my code:
Console.SetOut(new TextHelper());
and the class:
public class TextHelper : TextWriter
{
TextWriter console;
public TextHelper() {
console = Console.Out;
}
public override Encoding Encoding { get { return this.console.Encoding; } }
public override void WriteLine(string format, params object[] arg)
{
string s = string.Format(format, arg);
WriteLine(s);
}
public override void Write(object value)
{
console.Write(value);
System.Diagnostics.Trace.Write(value);
}
public override void WriteLine(object value)
{
Write(value);
Write("\n");
}
public override void WriteLine(string value)
{
console.WriteLine(value);
System.Diagnostics.Trace.WriteLine(value);
}
}
Note: I override just what I needed so if you write other types you should override more
You have three possibilities to do this, but it's not trivial. The main idea of all IDEs is that all of them are the parents of the child (debug) processes. In this case, it is possible to manipulate with standard input, output and error handler. So IDEs start child applications and redirect out into the internal output window. I know about one more possibility, but it will come in future