Configuration Section not loading with dynamically loaded Assembly
am 02.01.2008 16:05:34 von Paul BuckleyHi,
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(ConfigurationUserL evel.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!