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