> I can read the configuration from app.exe.config file, but I
> need to be able
> to read the configuration from all three config files.
> I remember reading a while ago about the possibility to
> link/chain/refer
> multiple config files together, but I cannot find that
> resource/article
> anymore.

The <appSettings> element supports a file attribute.  Just bring up MSDN and
type "<appSettings" into the index.  But since you've got 3 files, it's not
quite going to work for you.  If you only needed to read 2 files, it works
something like this...

Your main app.config file could have an <appSettings> section that looks
like so:

<appSettings file="extra.config">
  <add key="key1" value="key1 from app.config"/>
  <add key="key2" value="key2 from app.config"/>
</appSettings>

Then extra.config would have *only* an appSettings element as its root
element that looks like this:

<appSettings>
  <add key="key2" value="key2 from extra.config"/>
  <add key="key3" value="key3 from extra.config"/>
</appSettings>

When app settings are read, the linked file takes precedence.  Keys not
found there are pulled from the 'root'/main app.config file.  So given the
above files, here's what ConfigurationSettings.AppSettings[] would return
for each key:

key1 : key1 from app.config      (not found in extra.config)
key2 : key2 from extra.config    (extra.config overrides app.config)
key3 : key3 from extra.config    (not found in app.config)

Since you're working with 3 config files, some alternatives would be to just
use the builtin <appSettings> reader in the .NET class library to read an
arbitrary config file[1], or to use a variation that models per-dll
configuration files[2].

-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsight.com/mike

[1] http://www.bearcanyon.com/dotnet/#ConfigFileReader
[2] http://www.bearcanyon.com/dotnet/#AssemblySettings

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to