将 wcf 服务配置保存在单独的文件 RRS 提要中

Keeping wcf service configuration in separate file RRS feed

我需要将我的绑定、服务、行为保存在单独的或一个公共文件中,并将其加载到 app.config.I 尝试了很多方法都没有 work.Finally 我找到了一个 post 关于 this.But thios one 也不适用于 me.Can 谁能帮我解决这个问题。

显示错误无法打开配置文件 System.Configuration.ConfigurationErrorsException

<configuration>
 
  <system.serviceModel>
    <services configSource="Services.config" >
    </services>
 
    <bindings configSource="Bindings.config">
    </bindings>
 
    <behaviors configSource="Behaviors.config">
    </behaviors>
 
  </system.serviceModel>
 
</configuration>
And then you can put your configuration settings in separate files like the following:

Behaviors.config

<configuration>
 
  <system.serviceModel>
    <services configSource="Services.config" >
    </services>
 
    <bindings configSource="Bindings.config">
    </bindings>
 
    <behaviors configSource="Behaviors.config">
    </behaviors>
 
  </system.serviceModel>
 
</configuration>


I got this from below post

 http://blogs.artinsoft.net/Mrojas/archive/2011/01/06/Split-Config-files-in-several-files.aspx

https://whosebug.com/q`enter code here`uestions/858225/configsource-doesnt-work-in-system-servicemodel-or-its-subsections/858320

please help me to solve this?

您需要设置配置文件的属性:

将“复制到输出目录”的值设置为“始终复制”。service.config和behavior.config个文件都需要设置。

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
    <system.serviceModel>
        <services configSource="Services.config" >
        </services>
        <behaviors configSource="Behaviors.config">
        </behaviors>
    </system.serviceModel>
</configuration>