Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net <;appSettings/>;包含设置并参考另一个<;appSettings/>;另一个文件中的节?_.net_Visual Studio 2010_App Config - Fatal编程技术网

.net <;appSettings/>;包含设置并参考另一个<;appSettings/>;另一个文件中的节?

.net <;appSettings/>;包含设置并参考另一个<;appSettings/>;另一个文件中的节?,.net,visual-studio-2010,app-config,.net,Visual Studio 2010,App Config,我是否可以在我的app.config中有一个部分,该部分包含许多设置,但也引用另一个文件中的部分 这将允许我保留只有开发人员才感兴趣的配置选项,例如,在主窗口上显示调试输出的选项(非常混乱,但对我很有用),或者将某些文件保存到特定位置 具体来说,这就是我想要实现的目标: <!-- this is the appSettings section of the normal app.config file, which also contains everything else th

我是否可以在我的app.config中有一个
部分,该部分包含许多设置,但也引用另一个文件中的
部分

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

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

<!-- 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>

是。考虑到可能出现的场景数量,这有点少,但根据下面的引文,仅在appSettings标记的情况下才有合并

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

在ASP.NET中对此进行的测试(如下)表明,它使用
标记工作。在从属文件中使用诸如
标记之类的更高级的东西显然会出现问题,尽管我没有测试边缘情况。不能说ASP以外的部署技术;Machine.Config也没有经过测试

在web.config文件中:

    <appSettings file="_config\AppSettings.Config">
            <add key="testing-1" value="Web.Config" />
    </appSettings>
    <appSettings>
            <add key="testing-2" value="_config/AppSettings.config" />
    </appSettings>

在“\u config\AppSettings.config”文件中:



很可能是复制品,而不是复制品。这个问题比我的更一般,基本上是一样的。您希望您的app.config包含其他配置。如果不想部署第二个配置,只需确保删除已部署app.config中包含的app config。