Binary serialization/de-serialization in C++ and C#

Posted by 6pack kid on Stack Overflow See other posts from Stack Overflow or by 6pack kid
Published on 2011-01-13T07:16:31Z Indexed on 2011/01/13 9:53 UTC
Read the original article Hit count: 676

Filed under:
|
|
|
|

Hello.

I am working on a distributed application which has two components. One is written in standard C++ (not managed C++) and the other one is written in C#. Both are communicating via a message bus.

I have a situation in which I need to pass objects from C++ to C# application and for this I need to serialize those objects in C++ and de-serialize them in C# (something like marshaling/un-marshaling in .NET). I need to perform this serialization in binary and not in XML (due to performance reasons).

I have used Boost.Serialization to do this when both ends were implemented in C++ but now that I have a .NET application on one end, Boost.Serialization is not a viable solution.

I am looking for a solution that allows me to perform (de)serialization across C++ and .NET boundary i.e., cross platform binary serialization.

I know I can implement the (de)serialization code in a C++ dll and use P/Invoke in the .NET application, but I want to keep that as a last resort.

Also, I want to know if I use some standard like gzip, will that be efficient? Are there any other alternatives to gzip? What are the pros/cons of them?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about c++