<appSettings />是否可以包含设置并引用另一个文件中的另一个<appSettings />部分?

Dav*_*Dev 10 .net app-config visual-studio-2010

我可以<appSettings />在app.config中有一个包含许多设置的<appSettings />部分,但是它也引用了不同文件中的部分吗?

这将允许我保留只有开发人员应该感兴趣的配置选项,例如在主窗口上显示调试输出的选项(非常混乱但对我有用)或将某些文件保存到特定位置.

具体来说,这就是我想要实现的目标:

<!-- this is the appSettings section of the normal app.config file,
     which also contains everything else that app.config would -->
<appSettings configSource="AppSettings.config"> <!-- references another file -->
  <add key="deployment_config_option1" value="1"/>
  <add key="deployment_config_option2" value="2"/>
</appSettings>

<!-- this a new appSettings section of another file called DevSettings.Config
     which only contains settings us developers are interested in
     by keeping these settings in a different file, 
     I can ensure it's never deployed -->
<appSettings> <!-- references another file -->
  <add key="show_debug_on_screen" value="true"/>
  <add key="save_copy_to_desktop" value="false"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)

zan*_*lok 12

是.文档是有点薄给出可能的情形的数量,但按照报价低于说,有只在标签的appSettings的情况下进行合并.

由于对Web.config文件的任何更改都会导致应用程序重新启动,因此使用单独的文件允许用户修改appSettings部分中的值,而不会导致应用程序重新启动.单独文件的内容与Web.config文件中的appSettings部分合并.此功能仅限于appSettings属性.

在ASP.NET的情况下对此(下面)的测试表明它使用<add>标签.<clear>虽然我没有测试边缘情况,但在下级文件中使用像标记这样的发烧友的东西显然会出现问题.不能说ASP以外的部署技术; Machine.Config也未经过测试.

在web.config文件中:

    <appSettings file="_config\AppSettings.Config">
            <add key="testing-1" value="Web.Config" />
    </appSettings>
Run Code Online (Sandbox Code Playgroud)

在"_config\AppSettings.config"文件中:

    <appSettings>
            <add key="testing-2" value="_config/AppSettings.config" />
    </appSettings>
Run Code Online (Sandbox Code Playgroud)