SerializationException Type “is not marked as serializable” - But it is

后端 未结 4 1296
甜味超标
甜味超标 2021-01-01 19:21

In Windows Forms, .NET Framework 4.0, I am trying to Serialize an instance of a class I wrote.

The class is marked as Serializable, but the form that uses the class

4条回答
  •  离开以前
    2021-01-01 19:49

    [field:NonSerializedAttribute()]
    public event EventHandler BrazierCuttoffChanged;
    

    Had the same problem, the PropertyChanged EventHandler of my serializable NotifyObject base class was subscribed by some viewmodels which went into the serialization queue therefore. Adding the NonSerializedAddtribute to this EventHandler saved my day. :-)

提交回复
热议问题