Enumerations in WCF

Like other data types designed to go over the WCF wire (as it were) we need to mark the enum with a DataContractAttribute. Unlike classes, which use the DataMemberAttribute for any published methods we use the EnumMemberAttribute. For example

[DataContract]
public enum Status
{
   [EnumMember]
   None,
   [EnumMember]
   Running,
   [EnumMember]
   Failed,
   [EnumMember]
   Succeeded
}

Don’t forget to add a FlagsAttribute if you are requiring the enum to work as flags otherwise you’ll get an error from WCF when combining your flags, as the value will be unexpected.