سؤال

i have three applications. 1. MFC (Creates Named pipes and Read, Write to Named Pipes) 2. Service(Read or Writes Named Pipes) 3. WPF Application sends the Data to the service to write to the Named Pipes.

Flow goes like this. Firstly, MFC applicatiom create Named Pipes , then Service creates the Named Pipes Client to Read and Write to Pipes. WPF Application consumes the Service and Send the Data to be wriiten to named pipes.

Now can some one tell me How to write a c# object ( may be serialise ) to Named Pipes . Then how can i create the C++ object by reading back the c# object written to the Named pipes . and vice versa ( c++ object written to Named pipes then in Service i want to create the c# object from Named pipes)

هل كانت مفيدة؟

المحلول

Named pipes is a "low-level" transport, and it does not define how you should/could serialize/deserialize your data (it just transfers plain "data blocks", like byte[], or strings)

Probably what you are looking for is a serialization library, which would allow you to serialize an object in C# and deserialize it in C++, and vice versa.

Here is related question: Serialize in C++ then deserialize in C#?

So here is how it could go: You serialize your object in C# into a byte array/string, then write that array/string to a named pipe; then read the serialized data block from the named pipe in C++ application, and deserialize it into an C++ object. And vice versa.

The above post recommends google Protocol Buffers library for serialization/deserialization.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top