开发者

Nesting appSettings with the file attribute

I'm trying to pull off an inheritance chain of appSetting sectio开发者_Python百科ns (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.


This is just not alllowed. You can not specify another external AppSetting file from within the first external AppSetting file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜