我正在尝试使用BinaryFormatter深度克隆对象,但我收到此错误
Type 'Newtonsoft.Json.Linq.JObject' in Assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' is not marked as serialisable
有人可以帮帮我吗?
[Serializable]
public class MyClassObject
{
public JObject RandomJobject { get; set; }
public SheetInfo2 Clone()
{
using (MemoryStream memoryStream = new MemoryStream())
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(memoryStream, this);
memoryStream.Seek(0, SeekOrigin.Begin);
return (SheetInfo2)binaryFormatter.Deserialize(memoryStream);
}
}
}
PS:与此主题相关的帖子很少,但我找不到任何解决方案。 *我原来的班级在班上有更多的属性。