.NET 3.5 (C#) 网络上的命名管道
我正在努力让 .NET(不是 WCF)命名管道通过网络进行通信。 MSDN 文档 暗示这是可能的,而且很简单。但我的代码:
using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(servername, "myPipe", PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation))
...当 servername="localhost" 和管道服务器位于同一个盒子上时效果很好。但如果是另一台机器 - 无论我是否将服务器名称设置为 IP 地址、DNS 名称、NetBIOS 名称、UNC 路径等 - 都意味着管道永远不会连接。它实际上并没有失败,pipeClient.Connect()只是坐在那里。
各种论坛、博客和网站上有很多关于此问题的不同且相互冲突的帖子。谁能澄清事实并告诉我:如何让命名管道客户端从一台计算机上的一个 C# 应用程序连接到另一台计算机上运行的命名管道服务器?
I'm struggling to get a .NET (NOT a WCF) named pipe to communicate across the network. The MSDN documentation implies this is possible, nay trivial. But my code:
using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(servername, "myPipe", PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation))
... works great when servername="localhost" and the pipe server is on the same box. But if it's another machine - regardless whether I make servername an IP address, DNS name, NetBIOS name, UNC path etc - means the pipe never connects. It doesn't actually fail, pipeClient.Connect() just sits there.
There's so many different and conflicting posts on various forums, blogs and sites about this. Can anyone set the record straight and tell me: how do I get a Named Pipe Client to connect from one C# application on one machine to a Named Pipe Server running on an another machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在工作时这样做吗?公司防火墙或防病毒程序是否正在运行?检查 Windows 事件日志和开始栏上任务通知图标区域中的任何应用程序,以获取有关谁阻止此操作的提示。
Are you doing this at work? Is a corporate firewall or anti-virus program running? Check the windows event logs and any applications in your task notification icons area on your start bar for hints as to who is blocking this.