0

I've seen that NetNamedPipeBinding exists in C# and in C++ (source) and I would like to know if it's possible to use it to transmit datas between a C++ program and a C# application?

darkheir
  • 8,844
  • 6
  • 45
  • 66

2 Answers2

2

There's a good example here showing how to do IPC (Inter-Process Communication) between C++ and C#.

Colin Smith
  • 12,375
  • 4
  • 39
  • 47
1

If your C++ compiler is a recent version of Visual C++, with all the extensions to support writing managed code, then you can use WCF easily to pass data between a C++ program and a C# application.

If your C++ compiler doesn't support managed code extensions, you can still do it but it is a lot of work, because the WCF channel stack uses some layered proprietary protocols for message framing, security negotiation and message encoding, which you would need to reimplement on the C++ side if you can't use the managed implementation provided by WCF. See for example this question for the kind of issues which arise.

If you can't do managed C++ it is often much easier to forego some of the benefits provided by WCF and, depending on your requirements, either to:

  • use a managed COM-visible wrapper around a C# WCF service, consumed as a COM server in the C++ code; or
  • roll your own IPC mechansim using a named pipe directly, calling the WIn32 APIs on the C++ side and using the System.IO.Pipes types on the C# side.
Community
  • 1
  • 1
Chris Dickson
  • 11,964
  • 1
  • 39
  • 60
  • Yeah it wasn't that difficult using WCF! the only problem was that there is so little documentation about NetNamedPipeBinding in C++ that I had a really hard time to figure how to make it work, but then it was really easy! – darkheir Aug 21 '12 at 12:30