我有一个带有两个接口的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>
最佳答案
好像您将Identity放在错误的终点下。将其移动到端点地址=“ TaskManager端点”下的元素,而不是在mex下。
<endpoint address="TaskManagerEndpoint" binding="netTcpBinding"
bindingConfiguration="" name="TaskManagerEndpoint" contract="WcfServiceLibrary1.ITaskManager">
<identity>
<dns value="" />
<certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>