Is DataContract attributes required for WCF

Solution 1:

If I recall correctly(IIRC), if you don't use formal data-contract markers, it defaults to acting like a field-serializer. This will work, but is less easy to version, since private changes can break the client/server. IMO you should always formally decorate WCF types with the data-contract/data-member attributes. It will work without them, but for the wrong reasons (IIRC, originally it didn't work without formal markers).

Solution 2:

"Is DataContract attributes required for WCF"

Technically, no. This is dependent on whether you use the DataContractSerializer or not (which is the default on many bindings).

There are other options:

  1. Consider alternative serializers
  2. Try using Data Contract Surrogates (attributes are still required somewhere, but it does potentially mean u can leave your class untouched, if thats relevant)
  3. Rely on the serialization defaults for when you serialize classes without Data Contract attributes

Solution 3:

You can use several serializaton techniques with WCF, it's one of the nice adaptable things about it. Have a look:

http://msdn.microsoft.com/en-us/magazine/cc163569.aspx