c# - BinaryFormatter does not exist in CF. Solutions? -


i need serialize/deserialize obj in/from byte[] on compact framework there no binaryformatter, should do? thanks. class using on server side , want on client(a device windows mobile 6)

public class serializer {     public byte[] serializeobject(object obj)     {         if (obj == null)             return null;         using (memorystream stream = new memorystream())         {             binaryformatter formatter = new binaryformatter();             formatter.serialize(stream, obj);             return stream.toarray();         }     }      public object deserializeobject(byte[] bytes)     {         if (bytes == null)             return null;         binaryformatter formatter = new binaryformatter();         memorystream stream = new memorystream(bytes);         return formatter.deserialize(stream);     } } 

for scenario, might consider switching protobuf-net; not same format binaryformatter, both client , server need tweaks, binary serialization api works on both platforms, , typically smaller added extra. format google's "protocol buffers" encoding; fast, platform-independent, , designed flexible add properties etc. , free. fool gives away.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -