I need to serialize/deserialize obj in/from byte[] on compact framework but there is no BinaryFormatter, what should i do? Thanks. This is the class i am using on the server side and i want it also on the client(a device with 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);
}
}