[Mono-dev] System.Diagnostics configuration bug

Tomasz Noiński noix at sphere.pl
Sat Apr 28 19:10:57 EDT 2007


Hi,

I've found a bug in configuration of System.Diagnostics (i.e. stuff in
system.diagnostics section in the *.config file).
I filed a bug report (#81296), but there has been no answer for a
month. Maybe bugzilla isn't the place to file bugs anymore?

I'd be really glad for at least some pointers to how I could
help track this bug down.

The problem is that a .config file like that:

--- SwitchTest.exe.config ---
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
        <system.diagnostics>
                <switches>
                        <add name="t" value="1" />
                </switches>
                <trace>
                        <listeners>
                                <clear/>
                                <add name="configConsoleListener"
type="System.Diagnostics.ConsoleTraceListener" />
                                <add name="logfileListener"
                                       
type="System.Diagnostics.TextWriterTraceListener"
                                        initializeData="log.log" />
                        </listeners>
                </trace>
        </system.diagnostics>
</configuration>
--- End of SwitchTest.exe.config ---

...doesn't set the "t" switch.
If I comment out the "logfileListener" line, the "t" switch _is_ being
set.

I think it's because the "logfileListener" is created _twice_ by
DiagnosticsConfigurationHandler.AddTraceListeners().
When it's being created for the second time, AddTraceListener() throws
a "Sharing violation" exception:

--- exception dump ---
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invoc
ation. ---> System.IO.IOException: Sharing violation on path log.log
  at System.IO.FileStream..ctor (System.String name, FileMode mode, FileAccess access, FileShare share, Int32 buffer
Size, Boolean anonymous, FileOptions options) [0x00000] 
  at System.IO.FileStream..ctor (System.String name, FileMode mode, FileAccess access, FileShare share) [0x00000] 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess
,System.IO.FileShare)
  at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSi
ze) [0x00000] 
  at System.IO.StreamWriter..ctor (System.String path, Boolean append) [0x00000] 
  at (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool)
  at System.IO.File.AppendText (System.String path) [0x00000] 
  at System.Diagnostics.TextWriterTraceListener..ctor (System.String fileName, System.String name) [0x00000] 
  at System.Diagnostics.TextWriterTraceListener..ctor (System.String fileName) [0x00000] 
  at <0x00000> <unknown method>
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (object,object[])
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder bind
er, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] --- End of inner exception stack
 trace ---

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder bind
er, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] 
  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[]
 parameters, System.Globalization.CultureInfo culture) [0x00000] 
  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] 
  at System.Diagnostics.DiagnosticsConfigurationHandler.AddTraceListener (System.String name, System.String type, Sy
stem.String initializeData) [0x00000] 
--- end of exception dump ---

I tried to repair it myself, but I couldn't find the place where
DiagnosticsConfigurationHandler methods are called -- it's not
straightforward, machine.config is involved etc.

If you find the time, please look into this bug or give me some
pointers on how to proceed.

TIA,

Noix



More information about the Mono-devel-list mailing list