I use the binaryFormatter to serialize objects for sending. But as for the ADO.NET dataset, what is the best practice? I noticed that binary formatter is override by xmlformatter in case of dataset? how to reduce the size & increase the serialization speed?
1 Answer
You can tell it to use binary-mode instead of the legacy xml mode:
myData.RemotingFormat = SerializationFormat.Binary; You can also try running the serializer through GZipStream or DeflateStream, but this would probably require sending it as a BLOB rather than direct remoting.
I've also done some recent work looking at pushing DataTable through protobuf-net, here, including comparison metrics - even if you don't want the protobuf-tweaks, the data of numbers should help you choose between xml/binary and vanilla/gzip/deflate.
5 Comments
leppie
Kinda off topic, but do you know of a way to prevent the Schema being transferred on an untyped dataset?
Marc Gravell
@leppie - at a guess:
data.SchemaSerializationMode = SchemaSerializationMode.ExcludeSchema;leppie
Unfortunately that requires a typed dataset :( Which I cant use in my case (MS Sync framework 1.0).
Marc Gravell
@leppie how are you doing the serialize? You can include it as a parameter if it is you calling it -
XmlWriteMode.IgnoreSchema etc.leppie
Unfortunately, the Sync framework (well at least the version I am stuck with) hides all those details.