
 Rank: Guest Groups: Guest
Joined: 9/17/2007 Posts: 11,670 Points: -1,200
|
Date parsed: 01/01/2008 23:05:34 Date: Wed, 2 Jan 2008 07:05:34 -0800 (PST)
Hi,
I'm trying to gain access to a configuration section from within an assembly that has been loaded using Assemly.Load(byte[]).
There is one main exe (lets say myApp.exe) and one config file (myApp.exe.config) which contains the config section. The dll (myAssembly.dll) is a "plugin" and loaded on request. The reason we use the byte array version of Assembly.Load is that the dll can remain unlocked which allows us to overwrite it (and update the plugin with a new version via a file watcher without taking down the service).
I have tried ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) and also the same method but passing in a full path to the config file. Both return a Configuration object that does not contain my custom config section so a call to GetSection returns null.
If we load the Assembly using Assembly.Load(string) then everything works perfectly, but the Assembly file is locked and can't be updated.
Can anyone help me with why these two Load methods result in such different behaviour, and what the solution might be to get round it?
Currently I am just using "AppSettings" but this is not as clean as having individual config sections.
Thanks!
|