我試圖拉斷appSetting節(VS2010 C#)嵌套的appSettings有文件屬性
鑑於這種的產業鏈,
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>
這條線:
ConfigurationManager.AppSettings["derivedkey"]
拋出異常:
無法識別的屬性 '文件'。請注意,屬性名稱區分大小寫。 (... \ Derived.config line 1)
看起來App.config可以成功「歸檔」到Derived.config,但Derived.config無法「歸檔」到Base.config,因爲「文件」突然變成未知屬性。
這對我來說有點循環/困惑,因爲必須成功識別App.config中的「file」屬性才能到達Derived.config,其中同一個「file」屬性突然未知。
我遇到同樣的問題。你有沒有想過這個? – jonperl 2011-02-18 03:28:41
@jonperl這已經過了幾個月,但爲了記錄,我認爲這只是配置讀者的一個限制。不幸的是,我終於重新設計了我的配置文件,並考慮到了限制。 – with 2011-03-22 13:01:51
我做了同樣的事情。 – jonperl 2011-03-22 17:49:33