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

I am working on a distributed application that has two components. One of them is written in standard C ++ ( not managed by C ++ and works on the Linux platform), and the other is written in C #. Both transmit via the message bus.

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

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

I am looking for a solution that allows serialization (de) at the borders of C ++ and .NET, i.e. cross-platform binary serialization .

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

Also, I want to know if I can use some kind of standard like gzip, will it be effective? Are there any other gzip alternatives? What are their pros and cons?

thank

+5
source share
3 answers

gzip - () . , . , gzip .

( , ). ( ) ( .proto) . - .NET, (1 2 3)

+4

, Googles. .Net, ++, Java. .

http://code.google.com/p/protobuf/

+5

Another possibility is Thrift , it has even more backends and, if necessary, provides a good part of the code necessary for network communication - in case you want to reduce the scale.

If you need simple serialization of objects, I would look at json.org. There are many implementations of C ++ /. NET.

+3
source

All Articles