在启动WCF服务时,报错:
“net.tcp://localhost:8080/tcpTest”处带有协定“"ITestService"”的 ChannelDispatcher 无法打开其 IchannelListener。
在查看详细异常信息时:找到InnerException异常信息中,发现:
{"未提供服务证书。请在 ServiceCredentials 中指定服务证书。"}
解决方法:
将:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="TestBind" maxReceivedMessageSize="65536000">
<readerQuotas maxDepth="32" maxStringContentLength="819200" maxArrayLength="16384" maxBytesPerRead="8192" maxNameTableCharCount="16384" />
<reliableSession inactivityTimeout="00:05:00" />
<security mode="Message">
<security mode="Message">改为:
<security mode="Transport">
原因:
如果将mode改为message方式,这种方式是对消息加密或签名,因此必须要注定证书。
也可以指定证书位置:
<behaviors>
<serviceBehaviors>
<behavior name="CustomValidator">
<serviceCredentials>
<serviceCertificate
findValue="8e f9 c6 6f 4e a0 0c 49 4f 84 69 fb de c6 a7 e1 79 01 5b 6e"
x509FindType="FindByThumbprint"
storeLocation="CurrentUser"
storeName="My" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
参考链接: