I have some library code that is used from my application, and also used by a special .NET action in the Visual Studio installer project. In turn, the library code uses the Enterprise Library logging block for logging. How to get configuration information in a corporate library in the context of my user action running inside msiexec? Is it possible to reload the configuration mechanism in the code before I make any EntLib calls?
Update: I created a hack that seems to work, but relies on setting a non-public static field using reflection. It's a shame that EntLib is so closely related to the .NET ConfigurationManager.
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" );
Update 2: Although this hacking works in a test bench, when launched in the msiexec context, the assembly loader does not find the assemblies specified in the configuration file. Fuslogvw indicates that AppBase is the windows32 system directory, which makes sense. I don’t understand why the manifest dependencies of the assembly of custom actions were found (which are located in the [TargetDir] directory along with the assembly of custom actions), but dynamically loaded assemblies called in the configuration file are not. I see no way around this.