我有一个接口,接口实现和客户端现在当我尝试托管服务并在同一个控制台应用程序中使用客户端时。 我收到以下错误:
“无法连接到net.tcp:// localhost:8000 / ClassAService。连接尝试持续时间跨度为00:00:02.0150000.TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它127.0 .0.1:8000" 。
我冲浪,发现这是由于端口被防火墙阻止。 但它与我的情况不一样。 我验证了。 即使更改端口号后它也无法工作
我已经在http://www.codeproject.com/Questions/1015959/WCF-Client-Error-Could-not-connect-to-net-tcp-No-c?arn=0中发布了代码和app.config
I have a interface, interface implementation and the client Now when I try to host the service and use the client in the same console application. I get the following error:
"Could not connect to net.tcp://localhost:8000/ClassAService. The connection attempt lasted for a time span of 00:00:02.0150000. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000".
I surfed and found that it is due to port being blocked by Firewall. But its not the same with my case. I verified. It didn't work even after change the port numbers
I have posted the code and the app.config in http://www.codeproject.com/Questions/1015959/WCF-Client-Error-Could-not-connect-to-net-tcp-No-c?arn=0
最满意答案
您不应该在ClassA.StartServiceHost的using子句中实例化ServiceHost。 这将使ServiceHost在该方法退出之前进行处置。
考虑在控制台应用程序中的Console.ReadLine语句之前创建ServiceHost实例,然后在Console.ReadLine语句之后调用ServiceHost.Close和ServiceHost.Dispose。 只要您希望服务运行,ServiceHost就必须处于活动状态(未处理)。
You shouldn't instantiate the ServiceHost in a using clause in ClassA.StartServiceHost. This will make the ServiceHost dispose before that method is even exited.
Consider creating the ServiceHost instance before the Console.ReadLine statement in the console application, and then call ServiceHost.Close and ServiceHost.Dispose after the Console.ReadLine statement. The ServiceHost must be alive (not disposed) as long as you want the service to run.
WCF客户端错误:目标被拒绝(WCF Client Error : target refused)我有一个接口,接口实现和客户端现在当我尝试托管服务并在同一个控制台应用程序中使用客户端时。 我收到以下错误:
“无法连接到net.tcp:// localhost:8000 / ClassAService。连接尝试持续时间跨度为00:00:02.0150000.TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它127.0 .0.1:8000" 。
我冲浪,发现这是由于端口被防火墙阻止。 但它与我的情况不一样。 我验证了。 即使更改端口号后它也无法工作
我已经在http://www.codeproject.com/Questions/1015959/WCF-Client-Error-Could-not-connect-to-net-tcp-No-c?arn=0中发布了代码和app.config
I have a interface, interface implementation and the client Now when I try to host the service and use the client in the same console application. I get the following error:
"Could not connect to net.tcp://localhost:8000/ClassAService. The connection attempt lasted for a time span of 00:00:02.0150000. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000".
I surfed and found that it is due to port being blocked by Firewall. But its not the same with my case. I verified. It didn't work even after change the port numbers
I have posted the code and the app.config in http://www.codeproject.com/Questions/1015959/WCF-Client-Error-Could-not-connect-to-net-tcp-No-c?arn=0
最满意答案
您不应该在ClassA.StartServiceHost的using子句中实例化ServiceHost。 这将使ServiceHost在该方法退出之前进行处置。
考虑在控制台应用程序中的Console.ReadLine语句之前创建ServiceHost实例,然后在Console.ReadLine语句之后调用ServiceHost.Close和ServiceHost.Dispose。 只要您希望服务运行,ServiceHost就必须处于活动状态(未处理)。
You shouldn't instantiate the ServiceHost in a using clause in ClassA.StartServiceHost. This will make the ServiceHost dispose before that method is even exited.
Consider creating the ServiceHost instance before the Console.ReadLine statement in the console application, and then call ServiceHost.Close and ServiceHost.Dispose after the Console.ReadLine statement. The ServiceHost must be alive (not disposed) as long as you want the service to run.
发布评论