2011-07-19 86 views
2

参考有关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> 

任何帮助,将不胜感激....

回答

3

找到自己的答案,希望它有助于其他寻找它...

我发现worker_DoWork的该事件()不会被触发,所以加工。的RunWorkerAsync();如在下面的代码到你的windows服务

protected override void OnStart(string[] args) 
{      
    worker = new BackgroundWorker(); 
    worker.RunWorkerAsync(); 
    worker.DoWork += new DoWorkEventHandler(worker_DoWork);     
} 

删除客户端项目的服务基准,再次添加它,因为它能够修改您的app.config文件。

0

只是一个匆匆记,可以帮助一些人:即控制在Perkin Elmer两台计算机之间

此错误想出了 - 赛默飞世尔科技液体处理设备(机器人)。

McAfee Antivirus正在干扰其通信,并且卸载McAfee放逐了该错误。 MS Security Essentials Antivirus不会产生干扰。

相关问题