[Mono-dev] how to fix TextWriterTraceListener disposal problem

Atsushi Eno atsushieno at veritas-vos-liberabit.com
Wed Apr 13 04:06:49 EDT 2011


Hello,

I'm asking for some advice.

I was debugging some System.Diagnostics.Trace stuff and noticed that our
TextWriterTraceListener does not flush the stream correctly when our
program terminates.

It is because the TextWriter's Flush or Close is never called while
Stream is closed (typical "forgot to dispose" issue). But I couldn't
find how to safely invoke this close method while the stream is alive.

Do you have any ideas how to solve this problem? (I already tried to use
AppDomain.DomainUnload on the default appdomain, which was wrong, and
tried to create CriticalFinalizerObject-based wrapper for the
TraceListener, which was wrong too as the stream could be already GC-ed).

Atsushi Eno



More information about the Mono-devel-list mailing list