SysInternals' DebugView no longer works if used under .NET 4. Some research indicated that the new architecture of the framework did not allow for traces to be captured if a debugger was attached; in my case it's the Visual Studio debugger. Changing target framework from 4 to 3.5 makes it work again.
Anybody knows a way of getting DebugView to work under .NET 4 while having the Visual Studio debugger attached? I tried clearing the Listeners collection of the Trace class, but no luck.
Depending on your needs, there is a simpler workaround: just start your app without the debugger by using Ctrl-F5.
I had hoped to use DebugView to capture debug statements from a hosted Silverlight app that doesn't work in the debugger. Although this doesn't work as it did before .NET 4, launching my host without debugging does let the debugger statements through and they show up in DebugView.
I ran into this problem when I downgraded some projects from .NET 4.5 to .NET 4 - suddenly all my Debug View data disappeared (and I was directly PInvoking to ::OutputDebugString). Anyway, upgrade to late latest available version of Debug View (4.81) solved the problem.
.NET trace messages are emitted using the
OutputDebugString
function in the Windows kernel. This function, as documented in MSDN,Obviously, a native debugger will receive this message. This is meant by the remark that this behavior is by design. The reason the messages were passed on to other listeners such as DebugView before .NET 4.0 is that Visual Studio did not debug .NET code as a "native" debugger; DebugView has never worked when a native debugger is attached.
A workaround could be to add a
TraceListener
that forwards all messages to another process that has no debugger attached. The communication could be realized using any IPC mechanism. The following is a sample using TCP sockets.Server Application
This would be a simple stand-alone command line program that gets started and stopped automatically by the
TraceListener
class:TraceListener
Usage
This fixed the problem for me: