[英]Multiple App.Config files
我想分开我的app.config文件。 例如,我想将ServiceModel部分移动到同一项目中的另一个配置文件。 我怎样才能做到这一点?
谢谢。
您应该能够将configSource
属性设置为第二个文件(相对于第一个文件)的空元素。 请参阅此处了解如何为自定义部分启用它。
我找到了方法。 我改变了这样的标签。
<system.serviceModel>
<behaviors configSource="Behaviors.config">
</behaviors>
<services configSource="Services.config">
</services>
<bindings configSource="Bindings.config">
</bindings>
<extensions configSource="Extensions.config">
</extensions>
</system.serviceModel>
在我创建了Services.config文件后,我把它放了
<services>
<service behaviorConfiguration="ServiceBehavior" name="EntLib31ExceptionTest.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/ValidationService1/" />
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="CustomBinding"
contract="EntLib31ExceptionTest.IService"
behaviorConfiguration="Validation"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
我在Bindings,Behaviors,Extensions.config文件中所做的一样。
它有效
使用这样的东西:
<?xml version="1.0"?>
<configuration>
<appSettings />
<connectionStrings/>
<system.web>
<compilation debug="false" strict="false" explicit="true" />
</system.web>
<appSettings file="externalSettings.config"/>
</configuration>
据我所知,这是不可能的。
您可以做的是(如果我们谈论WCF代理)在您的代码中创建和配置您的代理。 这样你就不需要serviceModel部分了。
现在只需为您需要的数据定义自己的自定义部分,然后将其放在配置文件之外。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.