从 VB6 到 WCF 的命名管道

发布于 2024-09-24 16:00:36 字数 670 浏览 1 评论 0原文

我可以让 VB6 应用程序通过 WCF 端点调用与用 C# 编写的服务的命名管道连接吗?

VB6 项目利用命名管道与用 C++ 编写的服务进行通信。我想将 C++ 服务转换为 C#(最好是 .NET 4.0)。

VB6 项目使用 Win32 调用 CallNamedPipes向服务器发送消息。消息的有效负载是由以下结构组成的字符串。

 [command][data length][data if approprate to the message]

我目前无法转换应用程序的 VB6 端,但我想知道是否可以依靠 CallNamedPipe 函数向新的 WCF 服务发送消息,以及它们是否可以很好地协同工作。我会看到 WCF 服务的合约端基本上是一种接受我将解析的字符串的方法。

另外,由于 CallNamedPipes 可以接收 outputBuffer 参数中的返回数据,WCF 是否能够适应这一点?合同是这样的吗...

string DoSomething(string command)

谢谢您的帮助!

布莱恩

Can I have a VB6 app call a named pipe connection to a service written in C# with a WCF endpoint?

The VB6 project that makes use of named pipes to talk to a service written in C++. I would like to convert the C++ service to C# (.NET 4.0 preferably).

The VB6 project uses a Win32 call to CallNamedPipes to send a message to the server. The payload of the message is a string that consists of the following structure.

 [command][data length][data if approprate to the message]

I am not able to convert the VB6 side of the application at this time but I am wondering if I can rely on the CallNamedPipe function to send a message to a new WCF service and if they will play well together. I would see the contract side of the WCF service basically being one method that accepts a string that I will parse.

Also, since CallNamedPipes can receive return data in the outputBuffer parameter, would WCF be able to accomodate this? Would the contract be something like this...

string DoSomething(string command)

Thanks for your help!

Brian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吾性傲以野 2024-10-01 16:00:36

WCF is very good, but really shines when using WCF on both sides of the communication channel. Trying to hook up legacy code to a WCF service is tricky at best.

It will likely be easier to make your C# service use NamedPipeServerStream directly. This will give you complete control over how the connection and transfer is handled. That being said, there is nothing preventing you from doing both (implementing a custom NamedPipeServerStream channel, as well as exposing one or more WCF endpoints, from within the same program). This would provide a way to move forward if you ever want to upgrade the client, as well.

哎呦我呸! 2024-10-01 16:00:36

为什么不编写一个包装 WCF 客户端代理的 ComVisible 类,您的 VB6 代码可以像调用任何其他 COM 库组件一样调用该代理。

Why not write a ComVisible class wrapping a WCF client-side proxy, which your VB6 code could call just like any other COM library component.

倦话 2024-10-01 16:00:36

您能否使用 PInvoke

然后将 pinvoke 服务包装在 WCF 服务周围以方便互操作。

Could you call the C++ named Pipes application directly from your C# code using PInvoke

Then the wrap the pinvoke service around a WCF Service for easy interop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文