If you get this error, you are missing an assembly reference.
Fix with: Project ... Add Reference ... System.Runtime.Serialization.dll
Why?
The class DataContractAttribute, which can be found in the namespace System.Runtime.Serialization, is implemented in the assembly System.Runtime.Serialization.dll.
That assembly is not referenced by default.