WCF中的由于目标计算机积极拒绝,无法连接

1.第一种情况

百度上找到了这篇文章  http://blog.sina.com.cn/s/blog_6b44b2ba01016j0z.html

讲的是使用了using用完之后就释放了,得到启发,仔细检查了Host的代码

 

 

对比了Learning WCF第一章中的示例代码,发现用try finally来执行的

在finally中将服务关闭了

try

{

//打开服务的代码
//有2个Service打开

}
 finally
            {
                CloseHost(hostA);
                CloseHost(hostB);
            }

 

 

2.第二种情况

因为之前电脑崩溃过一次,导致本机的net.tcp服务没有激活

http://stackoverflow.com/questions/22562596/unable-to-access-wcf-service-using-net-tcp-binding

Finally with the help of this link: http://rohitguptablog.wordpress.com/2011/06/16/configuring-wcf-service-with-nettcpbinding/, I figured out what was going wrong. Actually I missed the third step in above link. The Net.Tcp services were not running.

 

====2015年09月14日更新====

发现这个问题有又出现了,本来设置的是自动启动Net.Tcp Listener Adapter

电脑重新开机后,这个服务没有自动启动

查看这个服务的属性-->依存关系

发现Net.Tcp Port Sharing Service没有自动启动

 

解决方法:

将Net.Tcp Port Sharing Service这个服务改为自动启动。

 

 

4.新建了website以及application。

website添加了net.tcp的binding之后

需要记得给application添加net.tcp的protocol

 

5.有可能没有安装wcf服务

https://help.genesys.com/cic/mergedProjects/wh_tr/mergedProjects/wh_tr_web_portal_marquee/desktop/activate_windows_communication_foundation_wcf.htm

Activate WCF for Windows Server 2016

    1. From the Start menu, select Administrative Tools > Server Manager.

    2. Select Add roles and features from the Dashboard.

    3. Select Next twice.

    4. Select Features.

    5. In the Features area, expand the:
      - .NET Framework 3.5 Features and select HTTP Activation and Non-HTTP Activation.
      - .NET Framework 4.6 Features and select WCF Services.

    6. Under WCF Services select:
      - HTTP Activation
      - Messsage Queuing (MSMQ) Activation
      - Named Pipe Activation
      - TCP Activation
      - TCP Port Sharing

 

posted @ 2015-07-17 10:43  ChuckLu  阅读(1853)  评论(0编辑  收藏  举报