Search code examples
wcfvb6named-pipes

Named Pipes from VB6 to WCF


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


Solution

  • 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.