Hi guys I'm creating a very simple socket server that lets its clients save its own object state based on Keys by sending it over the wire. I'm using a very simple protocol encoding the serialized object to base64 string and will be sent out as part of my custom xml format. I wanted to know if the serialization will still be the same if the client app runs on 32-bit and 64-bit Windows and using .net Framework? will this also be the same if all client apps are created using c++ but runs on different platforms?
+1
A:
Serialization between 32 and 64-bit CLRs shouldn't be a problem, but if you want to be able to serialize on non-.NET platforms, you shouldn't use the default binary serialization. Personally I wouldn't use that anyway, as it can be tricky to handle in terms of versioning etc.
There are plenty of other serialization options available:
- XML serialization (either the built-in or hand-rolled)
- Thrift
- YAML
- JSON
- Protocol Buffers (I declare an interest: I've written one of the ports of Protocol Buffers to C#)
All of these are likely to work better across multiple platforms. Some are human readable as well, which can sometimes be useful. (Protocol Buffers aren't human readable, but it's easy to dump a text version of a protocol buffer message.)
Some effectively build their own object model via a separate schema, whereas others will cope (to a greater or lesser degree) with your existing object model.
Jon Skeet
2010-07-21 06:36:45
+1 for YAML and Thrift
onof
2010-07-21 06:39:53
Actually I wanted to deserialize objects created on non-.net apps since I provided a way on my custom xml format to tell me some basic info of the encoded object like version and its type. Can you tell me a better way of doing it ?
powerbox
2010-07-21 06:43:57