PropertyChangedEventManager is not marked as serializable

If you ever get the error “PropertyChangedEventManager is not marked as serializable.” This is probably because you are implementing INotifiyPropertyChanged incorrectly.

The solution is to mark your PropertyChangedEventManager as NonSerialized.

#region INotifyPropertyChanged Members

[field: NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;


protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, e);
}
}

#endregion

2 comments:

  1. Thanks, this fixed the problem I had. (Including one I didn't even attribute to this scenario.)

    ReplyDelete