jee*_*_jk 3 c# wpf documents serializable cloning
我有一个system.document.table对象,我想将该对象标记为Serializable以便进行深度克隆。例外是程序集“ PresentationFramework,版本= 4.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35”中的类型“ System.Windows.Documents.Table”未标记为可序列化。
FlowTable original = new FlowTable();
original = objFlowTab.deepclone();
Run Code Online (Sandbox Code Playgroud)
其中objflowtab具有表对象
[Serializable]
public class FlowTable : Table
{ ....
....
public static class ExtensionMethods
{
// Deep clone
public static T DeepClone<T>(this T a)
{
using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream,a);
stream.Position = 0;
return (T)formatter.Deserialize(stream);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在formatter.Serialize(stream,a)中遇到错误;