vendredi 8 mai 2015

Exception not marked as serializable

With no changes to code (that I recall) formatter.Serialize fails for on type of object
It works for 5 other types tested
I have made no changes to that class (that I recall) - is is marked as Serializable It is a fairly simple class and has no reverence to a system.Windows.Documents.FlowDocument

How can I tack down the error and fix it?

public static T DeepClone<T>(T obj)
{
    using (var ms = new MemoryStream())
    {
        var formatter = new BinaryFormatter();

        try
        {
            formatter.Serialize(ms, obj);
        }
        catch (Exception Ex)
        {
            Debug.WriteLine(Ex.Message);
            Debug.WriteLine(Ex.Source);

A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll

Additional information: Type 'System.Windows.Documents.FlowDocument' in Assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.

InnerExeption is null

Aucun commentaire:

Enregistrer un commentaire