views:

305

answers:

3

I wrote following code

Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
Debug.AutoFlush = true;
Debug.Indent();
Debug.WriteLine("test");

Nothing is output in output window What's wrong?

A: 

Possible causes that I can think of:

  1. Do you compile the application in DEBUG mode?
  2. Do you run the application while debugging? Visual Studio has to listen to the application, and this is done when you are debugging the application.
  3. Do you configure somewhere debug listeners?
Michael
Thanks' for answering !! . The listener of Debug is a default, but How to configure it?
ffffff
+1  A: 

I use debug output in a slightly different way to your example:

        Trace.Listeners.Clear();
        DefaultTraceListener listener = new DefaultTraceListener();
        Trace.Listeners.Add(listener);
        Debugger.Log(1, "test", "oops i've crashed");

The debug output does go to the output window. Make sure that you are running as "debug" and not "release"

Calanus
Yeah- release mode seems like the obvious candidate.
RichardOD
A: 

Also worth checking: right-click in the output window, and ensure "Program output" is checked.

PaulS