ConfigSource 属性 - 在两个地方指定配置
我们有一个 WCF 服务,需要部署到 200 多个客户的服务器上。我们希望能够通过使用 configSource 属性使 web.config 的一部分可用于自定义,如下所示:
<bindings configSource="bindings.config" />
这允许我们在将来的升级中覆盖主 web.config 文件,同时不覆盖客户自己对各部分的修改我们决定以这种方式外化。不幸的是,这有一个问题 - 根据这篇文章,“当如果您使用 configSource 属性,则必须将整个部分移动到单独的文件中,因为不会合并元素设置。”这意味着我们放入外部文件中的任何部分现在都超出了我们的升级和更改范围,而不必弄乱客户可能已修改的外部文件。
有什么办法解决这个问题吗?我们能否鱼与熊掌兼得,还是必须在自我控制和为客户提供灵活性之间做出决定?
We have a WCF service that needs to be deployed to 200 plus customers' servers. We would like to be able to make a portion of the web.config available for customization by using the configSource attribute like so:
<bindings configSource="bindings.config" />
This allows us to overwrite the main web.config file with future upgrades while not overwriting customers' own modifications to the sections that we decide to externalize this way. Unfortunately, there's a problem with this - according to this article, "When you use the configSource attribute, you must move the entire section to a separate file because there is no merging of element settings." This means that any section we put in an external file is now outside of our reach for upgrades and changes without having to mess with the external files that the customer may have made modifications to.
Is there any way around this? Can we have our cake and eat it too, or do we have to decide between having control ourselves and giving our customers flexibility?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,看来没有办法解决这个问题,你只能用一种方法或另一种方法来做到这一点。最后,我们做出的决定是使用 configSource 并将 web.config 的某些部分外部化,我们知道这些部分不在我们的控制范围内,但我们的 web.config 的绝大多数仍可用于将来的修改。
Well it appears there's no way around this, you can only do it one way or the other. In the end the decision we made was to use configSource and externalize certain portions of the web.config, knowing that those would be outside of our control but that the vast majority of our web.config would still be available for future modifications.