Has anyone used the settings class?

W

Waldy

Hi there,
I added a settings component to my .DLL so that I can read in
the configuration settings. This created a DLLNAME.config file in the
output directory and everything seemed to be OK until I tried to deploy the
..DLL and then realised that no matter what I type in the .config file, the
..DLL always returns the default values. The .DLL is going to be called from
a VB Script, so what should I be using for a .config file that can be simply
edited in notepad when it is deployed?
 
J

John Liu

Hi,

I'm not 100% following the question, but here's my shot.

..NET reads the AppConfig once for an AppDomain - then it caches the
values and stops reading them again. So if you modify the config file
halfway don't expect the running application to suddenly be able to see
the new values.

By default, the config file is the name of the starting exe file +
".config" suffix. You can see/change the config file in setting up
your AppDomain. What this does mean though, is if you have two
executables A.exe and B.exe, both using DLLNAME.dll

Then you need by default A.exe.config as well as B.exe.config files.

Not sure if I managed to catch your question - I tried to cast a big
net :)
jliu - johnliu.net
 
W

Waldy

Hi John,
thanks for responding. My issue is that the values in the
..config file are not used, it appears as though the values are compiled into
the .dll. The .dll is instantiated via VB Script, so there is no
application as such.
 
W

Waldy

O.K. It's the old application must be an .exe thing. I created copied the
..config file from the output directory to the one where the application
(engine.exe) is that runs the VB Scripts and renamed it to engine.exe.config
and I get my modified settings.
 
J

John Liu

The ApplicationConfiguration classes will always use the default config
file specified in your AppDomain.

AppDomain.CurrentAppDomain.SetupInformation.ConfigurationFile

If you want to specify in your own DLL where to retrieve the file, you
might need to create your own AppDomain within the dll, set it up to a
different Config file, then load your ApplicationConfiguration within
that AppDomain.

You'll need to make some cross-domain calls. And it can look hairy...
(Actually I feel itchy thinking down this path already).

May want to re-think how you want to specify your config settings.

jliu
 

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