首页蓝耳朵|小小蓝耳朵广州图书馆外文室英语儿童读物资源介绍网佛教青年之友旧版收集永硕E盘Phonics Short Vowels Game 
无法连接到 http://localhost:8000/HelloIndigo/HelloIndigoService。TCP 错误代码 10061: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:8000。
所属栏目:WCF  时间:2011-07-11 18:33  作者:狼子
《学习WCF从原理到实践》(Learning WCF)P21页,全书第一个例子按书上写的第一步测试到最后,会有这个错

出错消息:

无法连接到 http://localhost:8000/HelloIndigo/HelloIndigoService。TCP 错误代码 10061: 由于目标计算机积极拒绝,无法连接。 127.0.0.1:8000。

出错代码:
string s = proxy.HelloIndigo();

出错原因:
原版书上有这一句:
Compile the solution and run the Host project first, followed by the Client project.

中译本把这一句省掉了,然后呢,没有给出这一句的操作,所以这个例子就出问题了

在Client启动前,要先启动Host的,因为HelloIndigo是通过Host寄存服务的,然后呢,Client要靠Host调用这个HelloIndigo服务,如果Host没有启动,Client就不可以调用到服务了

解决办法:
在解决方案上右击,选择属性,设置为“多启动项目”,启动顺序如下:
Host 启动
Client 启动
HelloIndigo 无

google的时候,好多人提问,就是没有找到确定的答案,把英文出错信息和解决办法也写出来:
error: Could not connect to http://localhost:8000/HelloIndigo/HelloIndigoService. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000.

my answer: right-click on the solution, select Properties from the context menu, select "Multiple startup projects", set them like this:
Host start
Client start
HelloIndigo none

hope that would help you guys... you are so lucky that you have the original edition. it took me 4 hours to figure out what is happening. It is my first WCF project, you know. just being study...
小楼宝宝的涂鸦花花(Imitater)的博客起名称骨测字皖ICP备06000023号-17