Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataContractSerializer missing from the .NET Compact Framework

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?

like image 480
Hermit Avatar asked Jan 31 '26 08:01

Hermit


1 Answers

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.

like image 174
Marc Gravell Avatar answered Feb 02 '26 21:02

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!