序列化:
Dictionary<string, Socket> dict = new Dictionary<string, Socket>();
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, dict);
byte[] sendByte=new byte[1024*1024*2];
ms.Read(sendByte, 0, (int)ms.Length);
反序列化:
MemoryStream ms=new MemoryStream(b);
BinaryFormatter bf = new BinaryFormatter();
dict = (Dictionary<string, Socket>)bf.Deserialize(ms);
为什么提示此异常:Socket不能序列化? |