2

我有一个带有两个接口的 WCF 服务库:FileManager 和 TaskManager。

我想将这些接口的两个端点组合成一个服务。

当我在一个接口上使用一个端点时它工作得很好IFileManager,然后在我制作另一个接口ITaskManager并添加一个新端点后,服务停止工作。它让我在 TaskManager 端点上停止,并在 FileManager 端点上出现错误:

System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.

如何解决?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
  <compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. -->
 <system.serviceModel>
   <diagnostics wmiProviderEnabled="false" />

   <bindings>
  <netTcpBinding>
    <binding name="TcpBindingRule" maxBufferPoolSize="2097152" maxBufferSize="2097152"
      maxReceivedMessageSize="2097152" />
  </netTcpBinding>
</bindings>

<services>
  <service behaviorConfiguration="Service1Behavior" name="WcfServiceLibrary1.FileManagerService">
    <clear />
    <endpoint address="FileManagerEndpoint" binding="netTcpBinding"
      bindingConfiguration="TcpBindingRule" name="FileManagerEndpoint"
      contract="WcfServiceLibrary1.IFileManager" listenUriMode="Explicit">
      <identity>
        <dns value="" />
        <certificateReference x509FindType="FindBySubjectDistinguishedName" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"
      listenUriMode="Explicit">
      <identity>
        <certificateReference storeName="My" storeLocation="LocalMachine"
          x509FindType="FindBySubjectDistinguishedName" />
      </identity>
    </endpoint>
    <endpoint address="TaskManagerEndpoint" binding="netTcpBinding"
      bindingConfiguration="" name="TaskManagerEndpoint" contract="WcfServiceLibrary1.ITaskManager">
      <identity>
        <dns value="" />
      </identity>
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://Markor:1991/filemanager" />
      </baseAddresses>
    </host>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="Service1Behavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

</system.serviceModel>
</configuration>
4

1 回答 1

0

看起来您将身份置于错误的端点下。将其移动到端点地址 =“TaskManagerEndpoint”元素下,而不是在 mex 下。

 <endpoint address="TaskManagerEndpoint" binding="netTcpBinding"
      bindingConfiguration="" name="TaskManagerEndpoint" contract="WcfServiceLibrary1.ITaskManager">
      <identity>
        <dns value="" />
        <certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" />
      </identity>
    </endpoint>
于 2012-05-03T05:35:08.387 回答