我想使用Web.config转换,该转换适用于发布也适用于调试.
当我发布Web应用程序时,Visual Studio会根据我的currenctbuild配置自动转换Web.config.当我开始调试时,如何告诉Visual Studio执行相同的操作?在调试启动时,它只使用默认的Web.config而不进行转换.
任何的想法?
如何Web.debug.config在visual studio 2010内置调试器中合并和使用?
我想要的app.config是这样的:
<configSections>
<sectionGroup name="QA_Environment">
<section name="databases" type="System.Configuration.NameValueSectionHandler"/>
<section name="storageSystems" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
<sectionGroup name="Production_Environment">
<section name="databases" type="System.Configuration.NameValueSectionHandler"/>
<section name="storageSystems" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
Run Code Online (Sandbox Code Playgroud)
...然后我就得到了正确的组和部分.但是我会对任何有效或更好的建议感到满意.我现在已经降低了我的愿望:
<configSections>
<sectionGroup name="QA_Environment">
<section name="appSettings" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
<sectionGroup name="Production_Environment">
<section name="appSettings" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
Run Code Online (Sandbox Code Playgroud)
我想这很好......我想知道的主要问题是,如果我可以将这些部分中的一个替换为根级别的appSettings ...而不必迭代它们并以编程方式添加或创建配置并保存它.我只希望用户能够选择一个环境,select事件将改变appSettings ...
我面临的一个限制是我引用的数据层需要保持原样....所以我基本上需要让我的app.config可以像目前这些其他项目一样访问......那就是ConfigurationManager.AppSettings [afdasdf]
如果需要澄清,请告诉我...谢谢
c# configurationmanager app-config appsettings custom-sections