A day in the life...

public class GeekEarth : Earth { }
posts - 14, comments - 22, trackbacks - 0

Friday, July 24, 2009

PropertyChangedEventHandler is not marked as serializable

My data-transfer-objects implement INotifyPropertyChanged, which was giving me a problem whenever I tried to serialise them over a Remoting session.  If you try to add [NonSerialized] to the event you get an error informing you that you can only apply this attribute to fields, and not properties.

The solution is pretty simple, I think the .NET compiler should do this by default.

   1:  [NonSerialized]
   2:  PropertyChangedEventHandler propertyChanged;
   3:  public event PropertyChangedEventHandler PropertyChanged
   4:  {
   5:    add { propertyChanged += value; }
   6:    remove { propertyChanged -= value; }
   7:  }

posted @ Friday, July 24, 2009 10:27 AM | Feedback (0) |

Powered by: