R – DataContractSerializer missing from the .NET Compact Framework

compact-frameworkdatacontractserializernetwindows-mobile

It appears that the DataContractSerializer isn't available in the .NET Compact Framework. I found this quite surprising, as I consider DataContractSerializer to be the Holy Grail of serialization, and one of the most widely useful classes introduced in .NET 3.

Is there a way to get the same functionality under the Compact Framework, that is, the ability to easily save and restore real-world object graphs using a textual format?

I'd rather keep away from the older, limited .NET serializers such as XmlSerializer and BinarySerializer.

I'm thinking perhaps there's a custom implementation of DataContractSerializer available, or maybe it's possible to use the code from Mono? Has anyone tried to do this?

Best Answer

Is it not available in CF 3.5? (edit: nope, I checked - indeed it is not). I know that XmlSerialzier is there, but yes, it does have some limitations.

Does it need to be text-based? On option is protobuf-net, which works on CF2.0, CF3.5, Silverlight, Mono, .NET 2.0, etc; and includes all the things you commonly need (including callbacks etc).

By the way, the Mono code (from "Olive") is, last time I looked, not very complete...

(edit) One other option might be Json.NET; from here, this now works on CF; since this is JSON, it is text-based, and should do most of what you need.