覆盖App.config中设置 [英] Overriding App.Config settings

查看:224
本文介绍了覆盖App.config中设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个app.config文件,该文件列出了具体的端点地址,还有一些额外的服务设置。我们想利用它放置在环境中设置外部配置文件来更改这些设置。我们希望它做的是动态读取该环境外部配置文件中没有硬编码值。

我知道有一种方法可以指定特定于该段部分的外部文件。有没有一种方法来动态设置这个位置?

解决方案

您的第一个问题 - 是的,你可以覆盖的任何配置部分(如<客户端> <绑定> 等不得部分基团,如< system.serviceModel> )与外部文件

 <客户configSource =yourCustomClient.config/>
 

Visual Studio将突出这有错误 - 但它的工作原理 - !这是Visual Studio的编辑器,在这里只是一个缺乏

您的第二个问题:不,我不相信有什么办法,使这个真正的动态 - 最好的,我能想到的是具有构建某种你的配置文件的XML转换和/或安装时间<。 / P>

We have an app.config file that lists specific endpoint addresses and also some additional service settings. We would like to change these settings using an external config file set by the environment that it is placed in. What we would like it to do is dynamically read the external config file for that environment without hard coding values.

I know there is a way to specify an external file in the section specific to that section. Is there a way to dynamically set this location?

解决方案

Your first question - yes, you can "override" any configuration section (such as <client>, <bindings> etc. not section group such as <system.serviceModel>) with an external file:

<client configSource="yourCustomClient.config" />

Visual Studio will highlight this with errors - but it works! - it's just a deficiency of Visual Studio's editor here.

Your second question: no, I don't believe there's any way to make this truly dynamic - the best I can think of is having some sort of an XML transformation of your config file at build and/or install time.

这篇关于覆盖App.config中设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆