参考有关Windows服务中的WCF服务的视频tutorial,我已经创建了一个示例WCF服务,并在Windows服务中使用netTcpBinding托管了该服务。 (因为我想这个WCF服务作为Windows服务运行)无法连接到net.tcp:// localhost ... TCP错误代码10061
它是一个简单的服务,它添加/删除/加载员工的详细信息,并由Windows窗体应用程序消耗。这工作得很好,当我建立整个解决方案包括wcf服务+ windows服务+客户端应用程序),但是当我想验证我的客户端不是直接引用解决方案中的项目时,所以我排除了我的解决方案中的两个服务(wcf + windows)。它停止工作抛出一个错误,阅读:
无法连接到net.tcp:// localhost:8010/EmployeeService.Service1 /。连接尝试持续时间为00:00:02.0180000。 TCP错误代码10061:由于目标机器主动拒绝它127.0.0.1:8010,因此无法建立连接。
重要的一点,这可能有助于回答:
- WCF服务和Windows服务具有相同的app.config
- Windows服务运行作为服务
这是我的客户端应用程序.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8010/EmployeeService.Service1/"
binding="netTcpBinding" bindingConfiguration="netTcpEndPoint"
contract="Service1.IService1" name="netTcpEndPoint">
<identity>
<userPrincipalName value="[email protected]" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
任何帮助,将不胜感激....