我在这里已经提过类似的问题:无法为 net.tcp WCF 服务添加服务客户端。当时问题已经得到解决。但现在同样的错误又出现了。我的 WCF 服务配置与上一个问题相同。我在这里再次发布它:
<system.serviceModel>
<services>
<service name="CoreService.Service1" behaviorConfiguration="beh1">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/Service1.svc/mex" />
</baseAddresses>
</host>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.IAccountService"/>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.IBoardService"/>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.ICategoryService"/>
<endpoint
address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="ultra"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
portSharingEnabled="false"
transactionFlow="false"
listenBacklog="2147483647"
sendTimeout="00:01:00">
<security mode="None">
<message clientCredentialType="None"/>
<transport protectionLevel="None" clientCredentialType="None"/>
</security>
<reliableSession enabled="false"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="beh1">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="True" />
<dataContractSerializer maxItemsInObjectGraph="65536" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
错误信息如下:
URI前缀不被识别。元数据包含一个无法解析的引用: 'net.tcp://localhost/Service1.svc'。无法连接到 net.tcp://localhost/Service1.svc。连接尝试持续了 00:00:02.0051147 的时间跨度。TCP 错误代码10061:因目标计算机积极拒绝,无法建立连接 127.0.0.1:808。 因为目标计算机积极地拒绝,所以没有连接可以建立 127.0.0.1:808 如果服务在当前解决方案中定义,请尝试构建解决方案并再次添加服务引用。
问题解决后,我没有更改任何配置,在过了几天后,它又开始显示相同的错误。我已经尝试了所有方法,但仍然无法解决。请帮忙!
更新: 我也能够通过浏览器使用 HTTP 访问它,但无法使用 "Add Service Reference "选项通过 net.tcp 协议访问。