They never get an instance, so don't expect to find them in any TraceSource collection. If you are not opposed to a little thought on the diagnostic configuration, you can interpret the output of this code:
class Program { static void Dump( ConfigurationElementCollection collection ) { foreach ( ConfigurationElement elm in collection ) { Console.WriteLine(); Console.WriteLine(elm.ToString()); Console.WriteLine(); foreach ( PropertyInformation prop in elm.ElementInformation.Properties ) { Console.Write( prop.Name + ": " ); if ( prop.Value == null ) { Console.WriteLine( "null" ); } else { ConfigurationElementCollection children = prop.Value as ConfigurationElementCollection; if ( children != null ) { Console.WriteLine( "children<" ); Console.WriteLine(); Dump( children ); Console.WriteLine( ">children" ); Console.WriteLine( ); } else { Console.WriteLine( prop.Value ); } } } } } static void Main( string[] args ) { Type tp = typeof( Debug ).Assembly.GetType( "System.Diagnostics.DiagnosticsConfiguration" ); PropertyInfo propSources = tp.GetProperty( "Sources", BindingFlags.NonPublic | BindingFlags.Static ); ConfigurationElementCollection sources = (ConfigurationElementCollection)propSources.GetValue( null, null ); Dump( sources );
Basically, each Source element has a property called "listeners", which is a collection of Listeners elements.
source share