Configuration Section not loading with dynamically loaded Assembly

P

Paul Buckley

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!
 
J

Jeff Johnson

I have the same problem and can't get around it.

Me too. And it hurts when I do "this."

(Today's lesson: learning how to reply to a post instead of starting your
own thread. Tomorrow's lesson: quoting.)
 
E

Eric B.

Hi ,

I have the same problem and can't get around it. Really no idea why the
system behaves this way.

Anybody with an answer?
I was hoping that after 10 months there would be an answer here!!

Thanks in advance


Yes.

Eric B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top