Updated my WCF Data Contract but client doesn’t receive the property values….

I spent about ten minutes wondering why I wasn’t getting the data I expected from my WCF service. I had just changed my data contract to have one more property/field and the data wasn’t being received by my client application. The client is in javascript, so it’s happy with whatever it receives. So no errors there, just an undefined property.

I looked at fiddler and noticed it didn’t come through there either. Now I chalked it up to a stale build and rebuilt again. Hmm…. Still undefined…wtf?

Well, simple issue with a simple fix. It turns out I , DUH, forget to tag the property as a DataMember. So the serializer ignored it thinking it was just an internal variable. No need to serialize or expose. Geez.

My fault but it was pretty funny when I started going back through my entities and contracts and started comparing them.

So, in short, if your client for your WCF service is not receiving the property you expect on the data contract, make sure you marked them properly. Easy to overlook when you are updating the DAL DTO’s, Business Entities, and then your Contract Entity.


/// <summary>
/// Gets or sets the reference.
/// </summary>
/// <value>
/// The reference.
/// </value>
[DataMember(Name= “Reference”)]
public string Reference { get; set; }

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.