连接到网络时,.Net 远程处理示例无法在我的电脑上运行
我试图通过事件和回调来理解.Net 远程处理。当我在互联网上阅读教程时,我发现了一篇文章:
codeproject: .NET Remoting Events Expanded< /a>
其中通过示例解释了此机制。我正在玩我在同一网页上下载的项目。
我在代码中唯一更改的是“RemotingEvents.Client.Form1.serverURI”,我已将其重新输入为本地主机(“tcp://localhost:15000/serverExample.Rem”)。 我在.Net 4.0下的Visual Studio 2010中编译了该项目,并在Win7 64位PC上测试了编译后的程序集,在这里我遇到了一个问题。
我已经运行服务器并启动它。之后我在其上连接了一个客户端,一切都很顺利,因为到目前为止还没有执行任何回调。当我尝试从客户端向服务器发送消息时出现问题。该消息到达服务器并按预期弹出在文本框中。之后,服务器尝试回调连接的客户端,但没有成功,并弹出一个异常,该异常返回给首先发送消息的客户端。
在尝试运行应用程序以使回调按预期方式传递之后,我发现当我将我的电脑与我所在的公共网络断开连接时,服务器客户端通信运行完美并且没有问题(即使有更多的客户)。
有谁知道为什么我在将我的电脑连接到上述网络时无法运行这些应用程序与回调正确通信的问题出在哪里?是否存在某种冲突?
谢谢你!
----- 编辑 (03/11/2011 17:15) -----
在克里斯·莱弗利第一次回答后,我正在设置防火墙,我发现 即使关闭防火墙,问题仍然存在。
I am trying to understand .Net remoting with events and callbacks. While I was reading tutorials on internet I have found an article:
codeproject: .NET Remoting Events Explained
where this mechanism is explained on an example. I was playing with the project which I have downloaded on the very same webpage.
The only thing I've changed in code was an "RemotingEvents.Client.Form1.serverURI", which I have retyped to a localhost ("tcp://localhost:15000/serverExample.Rem").
I compiled the project in Visual Studio 2010 under .Net 4.0 and I've tested the compiled assemblies on Win7 64-bit PC and here I came across a problem.
I've run server and started it. After that I have connected one client on it, everything went fine beacause none callback was executed so far. The problem appeared when I was trying to send a message from mine client to server. The message went through to server and popped up in the text box as it was supposed to. Right after that the server was trying to callback the connected client but did not get through and popped an exception which returned to client, who was sending the message in the first place.
After the time spent by trying to run the application so that the callbacks would pass through as they were supposed to, I have found out that when I disconnect my PC from a public network that I am in, the server-client communication runs perfectly and without problems (even with more clients).
Does anybody know where is the problem why I cannot run these applications communicating properly with callbacks while been connected with mine PC to a mentioned network? Is there some sort of a conflict?
Thank You!
----- EDIT (03/11/2011 17:15) -----
After first answer from Chris Lively I was setting the firewall and I have found out
that even with firewall swithed-off the problem still remains.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题与您的防火墙有关。
连接回网络,然后修改该网络类型的 PC 防火墙设置,以允许通过适当的端口访问您的 PC。
基本上,服务器正在尝试打开客户端 PC 上的端口。由于默认防火墙设置,客户端 PC 拒绝它。
如果您需要有关如何配置防火墙的帮助,请在 http://serverfault.com 上发布后续问题
The problem has to do with your firewall.
Connect back to the network then modify your PC's firewall settings for that network type to allow access to your PC along the appropriate port.
Basically, the server is trying to open a port on the client PC. The Client PC is denying it due to the default firewall settings.
If you need help with how to configure the firewall, please post a follow up question on http://serverfault.com