我想知道在以下结构中是否有方法或解决方法来配置文件:
App.Config中
<configuration>
<appSettings configSource="AppSett.config">
<add key="test1" value="test2"/>
</appSettings>
</configuration>
我的 AppSett.config 将如下所示:
<appSettings>
<add key="test3" value="test3"></add>
</appSettings>
答案 0 :(得分:3)
不,您不能使用部分信息的外部文件来链接而不是默认的配置结构。配置文件是符合配置架构的特殊文件,您无法在所描述的场景中使用它们。
答案 1 :(得分:1)
是的,这就是configSource的用途,但配置部分可以包含content或configSource属性,而不是两者。
答案 2 :(得分:0)
您可以使用file
属性而不是configSource
来实现此方法:
在您的示例中,您应该有文件App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings configSource="AppSett.config">
<add key="test1" value="test2"/>
</appSettings>
</configuration>
和AppSett.config
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="test3" value="test3"></add>
</appSettings>