I have a system.document.table object and i want to mark that object as Serializable for deep cloning it. the exception is Type 'System.Windows.Documents.Table' in Assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.
FlowTable original = new FlowTable();
original = objFlowTab.deepclone();
where objflowtab is having a table object
[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);
}
}
}
i am getting error in formatter.Serialize(stream,a);
Add a [Serializable] attribute to the class being serialized.
See details about C# serialization here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With