views:

42

answers:

0

I'm trying to pull off an inheritance chain of appSetting sections (VS2010 C#)

Given this,

Base.config

<appSettings>
    <add key="basekey" value="basevalue"/>
</appSettings>

Derived.config

<appSettings file="Base.config">
    <add key="derivedkey" value="derivedvalue" />
</appSettings>

App.config

<configuration>
    <appSettings file="Derived.config">
        <add key="mykey" value="myvalue" />
    </appSettings>
</configuration>

This line:

ConfigurationManager.AppSettings["derivedkey"]

Throws exception:

Unrecognized attribute 'file'. Note that attribute names are case-sensitive. (...\Derived.config line 1)

It appears that App.config can successfully "file" over to Derived.config, but Derived.config is unable to "file" over to Base.config because "file" suddenly becomes an unknown attribute.

It's a little circular/confusing to me since the "file" attribute in App.config must be recognized successfully in order to reach Derived.config, where the same "file" attribute is suddenly unknown.