How to share the same configuration files between several assemblies (executbles)?

  • Thread starter Thread starter gokoby
  • Start date Start date
G

gokoby

Hi,

I'm developing an application and we are having several different
executables for the same application.

In .net each executable got his own configuration file
(AssemblyName.exe.config).

I'm using the configuration management to get/set values from the
config file.
How can I share same configuration file for the whole application, no
matter how many executables I have in my app.

Thanks,
Koby
 
Koby,

I don't think that this is possible. Your two choices are to copy the
one file a number of times, and distributing that, or getting your values
from one file, using a custom configuration scheme (where you load the
properties yourself using whatever mechanism you want).

Hope this helps.
 
gokoby,
The help for configuration/appSettings suggests it can read name/value pairs
from an second file, however I have not tried it:

http://msdn.microsoft.com/library/d...-us/cpgenref/html/gngrfAppSettingsElement.asp

If you use custom configuration setting sections, as I do, then the above
may be less useful. Of course if you are using custom configuration setting
sections, you could define them so they themselves could read from an
external config file in a similar manner.

Hope this helps
Jay
 
Hi Koby,

Well, first off, DLLs use the config file of the exe that loads them, so if
you mean many DLLs in your app, you already have one config file.

However, if you mean that you have many EXEs (and I think you do), then the
best way I've found is to have all of the config files of the different EXEs
contain the name of a single configurable XML file that all apps will use:
<appSettings>
<add key="configfile" value="sharedconfig.xml" />
</appSettings>

The setup routine can create the config files for each of the EXEs and write
in an absolute path (C:\Program Files\Myapp\Myconfig.xml), or you could use
a relative path that your app interprets before opening the shared config
file. In fact, if you have a windows app, you would want this shared config
file to be in the user's "Documents and Settings\username\Application
Data\Appname" folder. That way, each user has their own settings,
regardless of where your app is deployed.

Hope this helps,
--- Nick
 
Back
Top