I want to print debug statements to the Output window(or anywhere else I can see it) in visual studio 2005. The advice I've seen has said to use
OutputDebugString("message");
and to ensure开发者_如何转开发 that I have
Options -> Debugging -> Redirect all Output Window text to the Immediate Window checked
while the code builds ok I don't see any output, what's the trick?
If you're using OutputDebugString, you can also use SysInternal's DebugView to see the output. Until you resolve your Visual Studio debugging issues, DebugView should do the trick.
You must run in Debug mode first.
Then use the following code (from MSDN):
class Test{
static void Main()
{
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
Debug.AutoFlush = true;
Debug.Indent();
Debug.WriteLine("Entering Main");
Console.WriteLine("Hello World.");
Debug.WriteLine("Exiting Main");
Debug.Unindent();
}}
You will see everything in the Output window. You may have to go to the View->Output menu to make this window visible in the IDE.
Alt-2 or View->Output to open the Output Window. By default it should already be open, it is generally in the tabbed window at the bottom of the IDE (but that will depend on your custom layout), and is labelled "Output".
The output is not directed to the console, you need to output to stdout
for that and create a console window for it.
If your code does hit that line, then it maybe:
RMB in your VS's output window:
Check if you have "Program Output" unchecked, if yes, check it!!!
Although this control exist in output windows's context menu, it does impact the output in immediate window as you redirect it.
精彩评论