What is the purpose of ExtensionDataObject in WCF? or How to make DataContract forward compatible?

 Posted by Senthilstayss on 3/19/2013 | Category: WCF Interview questions | Views: 11864 | Points: 40

A .NET serialization system supports backward-compatibility on custom data types naturally. However, sometimes we also need forward-compatibility for data types used in a WCF service.ExtensionDataObject property is used to achieve the Forward compatible in WCF.

Suppose that you have a service that exchanges some custom data types between clients. If one side updates the custom data type (adds some fields or properties) or uses a newer version, it is important to make sure that the other side can still work correctly with the updated data type instances without using the updated version of data.

Let see how can we achieve this in WCF.

1.First we need to make our Custom Data type to implement the IExtensibleDataObject interface.


public class Employee: IExtensibleDataObject



public string Name{ get; set; } [DataMember]

public string Address{ get; set; }

public ExtensionDataObject ExtensionData






2. Next we need to make sure that we haven't enabled the IgnoreExtensionDataObject property on ServiceBehaviorAttribute applied on your WCF service .This property is disabled by default.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response