title: How to use enterprise library logging in a .NET custom action
body: <p>I have some library code which is used from my application and is also used by a .NET custom action in a Visual Studio installer project.  The library code in turn uses the Enterprise Library logging block to do its logging.  How can I get configuration information to the Enterprise Library in the context of my custom action running inside msiexec?  Is it possible to bootstrap the config mechanism in code before I make any calls to the EntLib?</p>
  
  <p>Update: I've produced a hack that seems like it will work but relies on setting a non-public static field using reflection. It's a shame that EntLib is so tightly coupled to the .NET ConfigurationManager.</p>
  
  <pre><code>var factory = new LogWriterFactory( new FakeConfigSource( "foo.config" ) );
  var field = typeof ( Logger ).GetField( "factory", BindingFlags.Static | BindingFlags.NonPublic );
  field.SetValue( null, factory );
  Logger.Write( "Test" );
  </code></pre>
  
  <p>Update 2: Although that hack works in a testbed, when run in the context of msiexec, the assembly loader does not find the assemblies referenced in the config file.  Fuslogvw indicates that AppBase is the windows system32 directory, which makes some sense.  What I don't understand is why the custom action assembly's manifest dependencies (which are in the [TargetDir] directory alongside the custom action assembly) are found, but dynamically-loaded assemblies called out in the config file are not.  Can't see any way around this.</p>