Bug in Debug.Listeners?

  • Thread starter Thread starter Fred Mellender
  • Start date Start date
F

Fred Mellender

When I code:
Debug.Assert(false, "this is a message");
it works fine, and out comes the dialog box.

When I code
Trace.Listeners.Clear();
Debug.Assert(false, "this is a message");

No message is output.
In the debugger I see that clearing the Trace Listeners clears the Debug
Listeners. This is a problem since I am using the Trace Listeners for
logging and the debug listeners for debugging. Is this a bug? I am using
C# standard, MDE 2002.
 
Fred said:
When I code:
Debug.Assert(false, "this is a message");
it works fine, and out comes the dialog box.

When I code
Trace.Listeners.Clear();
Debug.Assert(false, "this is a message");

No message is output.
In the debugger I see that clearing the Trace Listeners clears the Debug
Listeners. This is a problem since I am using the Trace Listeners for
logging and the debug listeners for debugging. Is this a bug? I am using
C# standard, MDE 2002.

I don't think MS considers this a bug - the Debug and Trace classes
share the same set of listeners. I agree with you that this should not
be the case. It's a total break of OO encapsulation.

You might want to look into the log4net logging framework.
 
Back
Top