A day in the life...

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

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:  }

Print | posted on Friday, July 24, 2009 10:27 AM |

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 3 and 5 and type the answer here:

Powered by: