There are situations in which serialization is required for persisting state of objects from WCF services. Starting with .NET Framework 3.0, you can serialize objects exposed by WCF services taking advantage of the
DataContractSerializer class (which inherits from
XmlObjectSerializer). The usage of such a class is not so different from other serialization classes. The only need is that you must mark your serializable classes either with the
Serializable or with the
DataContract attribute and, in this case, their members with the
DataMember attribute. To see how this works in code, create a new WCF service project within Visual Studio 2010 (see Chapter 41, “Creating and Consuming WCF Services ...