不运行VS时WCF连接被拒绝 [英] WCF connection refused when not running VS

查看:93
本文介绍了不运行VS时WCF连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在VS中运行时,没有任何错误,并且发现Web服务没有问题.如何在不使用VS的情况下使其正常工作-又是为什么VS在另一台计算机上找到端口.为了验证VS是否正在通过网络查找服务,我远程登录到服务器并关闭了该服务,因此它失败了,这意味着它必须在VS中使用Web服务.

当我不在VS下运行时,出现以下异常:

System.Reflection.TargetInvocationException:调用的目标引发了异常. ---> System.ServiceModel.EndpointNotFoundException:无法连接到net.tcp://cgy-ztitestpc2:4006/PICS/DiagnosticService.连接尝试持续时间为00:00:02.1093615. TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它155.191.148.115:4006. ---> System.Net.Sockets.SocketException:无法建立连接,因为目标计算机主动拒绝它155.191.148.115:4006

When I run in VS, I get no errors and it finds the webservice no problem. How can I get it to work without being in VS - aka why is VS finding the port on another machine. To verify that VS is going across the network to find the service, I remote login to the server and shut down the service and so it fails which means it must be using the web service in VS.

When I don''t run under VS, I get the following exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://cgy-ztitestpc2:4006/PICS/DiagnosticService. The connection attempt lasted for a time span of 00:00:02.1093615. TCP error code 10061: No connection could be made because the target machine actively refused it 155.191.148.115:4006. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 155.191.148.115:4006

推荐答案

最可能的原因是您在运行时在VS中,它使用与在VS之外运行时不同的app.config副本.假设您的WCF配置位于该文件中.检查并确认是否是这种情况.
Most likely reason is that when you run from VS it uses a different copy of app.config from when you run it outside VS. Assuming that your WCF config is in that file. Check and see if this is the case.


我已经检查了app.config,它很好.例如,我在同一台机器上有一个测试门户和一个生产门户.当我想将其投入生产时,我创建了生产门户(有问题的门户).测试门户正在正常运行,并且运行正常.

因此,为了进行测试,我将配置文件更改为测试门户(5006),它可以正常工作.然后,我转到生产门户(4006),然后失败.

两种服务都部署在同一台计算机上.由于某种原因,同一配置文件在VS下运行,但不在VS外部运行.可以在外部找到测试门户,但不能在生产门户中找到.在VS中,它可以找到两个门户.

另外,当我从服务器运行时,由于服务是本地的,它会找到门户.
I have checked the app.config and it is good. For example, I have a test portal and a production portal on the same machine. I created the production portal (the one having problems) when I wanted to put it into production. The test portal was working & is working fine.

So, to test, I changed the config file to the test portal (5006) and it works. I then change to the production portal (4006) and then it fails.

Both services are deployed on the same machine. For some reason the same config file runs under VS but not outside of VS. Can find the test portals outside but not the production portals. In VS, it can find both portals.

Also, when I run from the server, it finds the portals because the services are local.


好,今天的错误消失了.我认为它消失了,因为我先关闭然后重新登录,现在它刷新了连接并可以找到Web服务.

因此,只需重启即可解决类似问题.
OK, the error went away today. I think it went away because I shut down and then relogged in and now it refreshed connections and could find the web service.

Therefore, simply rebooting might help those w/ a similar issue.


这篇关于不运行VS时WCF连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆