這是我的序列化和反序列碼C#序列化異常
public byte[] DTSerialize(object dt)
{
MemoryStream stream = new MemoryStream();
System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(stream, dt);
return stream.GetBuffer();
}
public object DTDeserialize(byte[] buffer)
{
MemoryStream stream = new MemoryStream(buffer);
System.Runtime.Serialization.IFormatter formatter = new BinaryFormatter();
return formatter.Deserialize(stream) as object;
}
而且這次調用方法的代碼
List<Series> ser = new List<Series>();
foreach (Series item in chartControl1.Series)
{
ser.Add(item);
}
byte[] btt = DTSerialize(ser);
但是當我調用代碼這個異常拋出
未處理的異常類型'System.Runtime.Serialization.SerializationException'發生在 mscorlib.dll
附加信息:在 組件類型 'DevExpress.XtraCharts.Series' 'DevExpress.XtraCharts.v14.1,版本= 14.1.4.0, 文化=中性公鑰= b88d1754d700e49a' 未標記爲 序列化。
你可以使用JSON作爲您的序列化格式? – oleksii
什麼是ser?它是'DevExpress.XtraCharts.Series對象嗎? – Akansha
不,這是贏的應用程序 – lkmcelik