[求助]请教一个对象序列化和反序列化的问题!!!!
public static byte[] doSerialize(object obj)
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formater=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream ms=new System.IO.MemoryStream();
formater.Serialize(ms,obj);
byte[] info=ms.ToArray();
ms.Close();
return info;
}
private System.Collections.ArrayList doDeserialize(byte[] bt)
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formater=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream ms=new System.IO.MemoryStream(bt);
ms.Position=0;
System.Collections.ArrayList NameList=(System.Collections.ArrayList)formater.Deserialize(ms);
ms.Close();
return NameList;
}
我用以上两个方法对ArrayList进行序列化和反序列号(在服务端序列化,通过网络传到客户端反序列化),但总是出现以下异常,请问要怎样解决?非常感谢!!!!
未处理的“System.Runtime.Serialization.SerializationException”类型的异常出现在 mscorlib.dll 中。
其他信息: BinaryFormatter 版本不兼容。应为版本 1.0。接收到的版本为 16777216.50331648。