进程间通信:MFC 服务器、.NET C# 客户端
我有两个 MFC C++ 桌面应用程序,它们使用命名管道交换字符串命令。一切都很好而且可靠。
现在,我必须使用 SilverLight 控件添加用 .NET C# 编写的客户端。我知道如何在 C# 中执行命名管道。但我第一次尝试混合这些失败了:无法将客户端连接到正在运行的服务器。
我是否缺少任何东西并且“混合坚果”模式必须起作用?还是“语言障碍”?
I have two MFC C++ desktop applications exchanging string commands using named pipes. All good and reliable.
Now, I have to add clients that are written in .NET C# using SilverLight controls. I know how to do named pipes in C#. But my first attempt to mix those failed: cannot connect clients to running servers.
Is there anything I am missing and that "mixed nuts" schema must work? or it's a "language barrier"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您尝试使用 WCF 进行通信,据我所知,
NetNamedPipeBinding
对于 Silverlight 不可用,并且如果您尝试执行 P/Invoke,则浏览器内运行的 Silverlight 应用程序将被阻止浏览器的安全限制。您确实可以通过 Silverlight 插件进行消息传递。 Paul Stubbs 有一个 博客文章展示了它在 Silverlight 3 中的工作原理。
只要您的 Silverlight 应用程序在浏览器中运行并且您必须与 MFC 服务器通信,您就必须实现除命名管道之外的其他协议。而且我认为您不允许使用 P/Invoke(如果 Silverlight 应用程序耗尽) - 浏览器。这是 Silverlight 的限制。
Assuming you try to use WCF for communication,
NetNamedPipeBinding
is not available for Silverlight as far as I know, and if you try to do P/Invoke that will be blocked from a Silverlight app running inside a browser due to security constraints of the browser.You do have messaging across Silverlight plug-ins available. Paul Stubbs has a blog post showing how that works in Silverlight 3.
As long as your Silverlight app runs in a browser and you have to communicate with a MFC server you have to implement some other protocol besides named pipes. And I don't think you are allowed to use P/Invoke if the Silverlight app runs out-of-browser either. It's a limitation of Silverlight.
如果您愿意在那里处理 COM Interop可能是一种方式。
它将让您与具有 COM Interop 的本地应用程序进行通信。然后,您可以使用可用的任何内容将消息从 Silverlight 通过管道传输到您想要的应用程序,因为 COM 对象没有与 Silverlight 相同的限制。这需要 Silverlight 4,并且还需要在客户端设置 COM Interop 目标。
If you are willing to deal with COM Interop there might be a way.
It will let you communicate with a local app that has COM Interop. You can then pipe the messages from Silverlight to the app that you want using whatever is available, since the COM object doesn't have the same restrictions as Silverlight. This would require Silverlight 4, and also setting up that COM Interop target on the client side.
对于查看此旧线程的任何人,一种方法是使用 http 轮询创建双工 WCF 服务 - 然后 silverlight 客户端可以与 WCF 服务通信,并且该服务可以将消息传递到 MFC 应用程序。
更多阅读:
http://msdn.microsoft.com /en-us/library/cc645027(v=vs.95).aspx
For anyone looking over this old thread, one way to go would be to create a duplex wcf service using http polling - the silverlight client can then communicate with a wcf service and the service can pass messages to the MFC app.
More reading:
http://msdn.microsoft.com/en-us/library/cc645027(v=vs.95).aspx