【发布时间】:2024-01-13 22:48:02
【问题描述】:
我正在尝试为基于 net.tcp 的 WCF 服务添加客户端。当我使用“添加服务引用”并提供此 URL:net.tcp://localhost/service1.svc 时,会出现以下错误。
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 如果服务定义在 当前解决方案,尝试构建解决方案并添加服务 再次参考。
我检查了 WCF 非 http 服务的 Windows 组件,但它们已经安装。这是快照:
如您所见,它们是为 .NET 3.5.1 安装的,而我的服务是在 .NET 4.5 中构建的。这是问题吗?我应该如何解决它?因为 Windows 组件列表中没有 .NET 4.5 的选项。
以下是我的 WCF 服务的配置:
<system.serviceModel>
<services>
<service name="CoreService.Service1" behaviorConfiguration="beh1">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/Service1.svc"/>
</baseAddresses>
</host>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.IAccountService"/>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.ICategoryService"/>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.ICommonService"/>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.IFollowerService"/>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.IInterestService"/>
<endpoint
binding="netTcpBinding"
bindingConfiguration="ultra"
contract="CoreService.IInviteService"/>
<endpoint
address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="ultra"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxConnections="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="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
<dataContractSerializer maxItemsInObjectGraph="65536" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
【问题讨论】: