Where does System.Diagnostics.Debug.Write output appear?
c#, debugging
Solution
As others have pointed out, listeners have to be registered in order to read these streams. Also note that `Debug.Write` will only function if the `DEBUG` build flag is set, while `Trace.Write` will only function if the `TRACE` build flag is set.
Setting the `DEBUG` and/or `TRACE` flags is easily done in the project properties in Visual Studio or by supplying the following arguments to csc.exe
`/define:DEBUG;TRACE`
Problem
The following C# program (built with `csc hello.cs`) prints just `Hello via Console!` on the console and `Hello via OutputDebugString` in the DebugView window. However, I cannot see either of the `System.Diagnostics.*` calls. Why is that? ``` using System; using System.Runtime.InteropServices; class Hello { [DllImport("kernel32.dll", CharSet=CharSet.Auto)] public static extern void OutputDebugString(string message); static void Main() { Console.Write( "Hello via Console!" ); System.Diagnostics.Debug.Write( "Hello via Debug!" ); System.Diagnostics.Trace.Write( "Hello via Trace!" ); OutputDebugString( "Hello via OutputDebugString" ); } } ``` Is there maybe some special command-line switches required for `csc`? I'm not using Visual Studio for any of my development, this is pure commandline stuff.