C# WCF:将编程配置转换为app.config

C# WCF:将编程配置转换为app.config,c#,.net,wcf,netnamedpipebinding,C#,.net,Wcf,Netnamedpipebinding,我有以下工作编程配置(服务器端) 正在尝试将其转换为app.config的代码: <system.serviceModel> <bindings> <netNamedPipeBinding> <binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"

我有以下工作编程配置(服务器端)

正在尝试将其转换为
app.config
的代码:

    <system.serviceModel>
<bindings>
  <netNamedPipeBinding>
    <binding
             closeTimeout="00:01:00"
             openTimeout="00:01:00"
             receiveTimeout="00:10:00"
             sendTimeout="00:01:00"
             transactionFlow="false"
             transferMode="Buffered"
             transactionProtocol="OleTransactions"
             hostNameComparisonMode="StrongWildcard"
             maxBufferPoolSize="524288"
             maxBufferSize="65536"
             maxConnections="10"
             maxReceivedMessageSize="65536">
      <security mode="Transport">
        <transport protectionLevel="EncryptAndSign" />
      </security>
    </binding>

  </netNamedPipeBinding>
</bindings>

<services>
  <service name="ServerApp.RequestHandler">
    <host>
      <add baseAddress="net.pipe://localhost/" />
    </host>
      <endpoint address="net.pipe://localhost/Request/"
              binding="netNamedPipeBinding"
              contract="AppLib.RequestInterface" />
  </service>
</services>

但是,这似乎不起作用-即客户端无法连接到该服务器

我的app.config代码是否有问题?
或者我必须通过编程告诉.NET使用app.config中的配置吗

否,除了根据服务类型在配置中正确分配类型/名称之外。。。看起来您已经正确地完成了,您不需要做任何其他事情来指向配置


我没有解析配置,但老实说,您可能应该使用来设置服务。这可能是导致您的服务无法工作的最小的小错误、输入错误或错过的设置。我经常说XML可能是人类可读的,但它很少是人类可编辑的。。。IMO WCF配置属于这一阵营:-)

我认为添加MetadateExchange的mex端点可能会解决这个问题,不确定,但请尝试一次。
或者您最好在“跟踪服务”上找到确切的问题。

这个工具似乎有些过时了。我无法打开.NET 4.0程序集(它告诉我该程序集的目标是.NET版本比该工具支持的版本更新)。我正在尝试添加一个新服务它就在那里的某个地方。。。对于旧版本的框架,您可能看到了错误的路径。或者,您应该能够通过visual studio“工具>WCF服务配置编辑器”菜单项访问它
    <system.serviceModel>
<bindings>
  <netNamedPipeBinding>
    <binding
             closeTimeout="00:01:00"
             openTimeout="00:01:00"
             receiveTimeout="00:10:00"
             sendTimeout="00:01:00"
             transactionFlow="false"
             transferMode="Buffered"
             transactionProtocol="OleTransactions"
             hostNameComparisonMode="StrongWildcard"
             maxBufferPoolSize="524288"
             maxBufferSize="65536"
             maxConnections="10"
             maxReceivedMessageSize="65536">
      <security mode="Transport">
        <transport protectionLevel="EncryptAndSign" />
      </security>
    </binding>

  </netNamedPipeBinding>
</bindings>

<services>
  <service name="ServerApp.RequestHandler">
    <host>
      <add baseAddress="net.pipe://localhost/" />
    </host>
      <endpoint address="net.pipe://localhost/Request/"
              binding="netNamedPipeBinding"
              contract="AppLib.RequestInterface" />
  </service>
</services>