将设置移动到另一个配置文件 [英] Moving Settings to another config file
问题描述
是否可以像使用 connectionStrings 或 appSettings 那样将 applicationSettings 移动到另一个配置文件?
Is it possible to move applicationSettings to another config file as it is possible with connectionStrings or appSettings?
当我使用设计器为我的 Web 应用程序创建设置时,我会在我的 web.config 中获取 applicationSettings 部分,例如:
When I create Settings for my web application using the designer I get applicationSettings section in my web.config such as:
<applicationSettings>
<TestWebApplication.Properties.Settings>
<setting name="AnotherSetting" serializeAs="String">
<value>Another setting value</value>
</setting>
</TestWebApplication.Properties.Settings>
</applicationSettings>
我希望能够将它们移动到另一个文件中,例如 appSettings:
I would like to be able to move them to another file like appSettings:
<appSettings configSource="configappsettings.config"/>
我正在处理一个项目,该项目具有通过设计器生成的类访问的大量设置,并且 web.config 在多个环境之间极难维护.如果我可以强制 Settings 类使用 appSettings 而不是 applicationSettings 会更好.
I'm working with a project that has lots of settings accessed through class generated with designer and web.config is extremely hard to maintain between multiple environments. It would be even better if I could force Settings class to use appSettings not applicationSettings.
有可能吗?
预先感谢您的帮助.
推荐答案
这个问题很久没有被标记为答案.好吧,在 marc_s 答案下,有一些评论解释说这是不可能的.我不想将 marc_s 答案标记为已接受的答案,因为评论所说的与答案完全相反.所以答案是,不幸的是,这是不可能的.
This question was not marked as answer for quite a long time. Well, under marc_s answer there are comments that explain that this is impossible. I didn't want to mark marc_s answer as accepted answer because the comments say exactly opposite thing than the answer. So the answer is that, unfortunately, it is not possible.
这篇关于将设置移动到另一个配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!