Tuesday, 12 April 2011

Debug and Trace messages not showing in DebugView after upgrading to .NET 4.0

Just a heads up to anyone upgrading to .NET 4.0, and finding their debugging not working.
I have been spending the day scratching our heads over why our stage deployment isn’t writing debugging messages to DebugView, after a recent upgrade to .NET 4.0. Before, in v1.1, v2.0 and v3.5 it was working fine, so why has it stopped now?
We have since found that functionality was removed from .NET 4.0 – therefore is by-design.
If you have any applications which use:

Debug.Write();  
Debug.WriteLine();  
Debug.Print(); 
Trace.Write();  
Trace.WriteLine();  
Trace.Print();

These will only appear while Visual Studio is debugging the application. For any environment where you are not doing any attach-to-process managed debugging, you see nothing.
Therefore, you may have to investigate one of the many logging applications e.g.
However, the System.Diagnostics.DefaultTraceListener will still not render any output, when configured by these frameworks.