Search code examples
c#.netwcfdatetimenullable

Added DateTime? DataMemberto DataContract - existing clients fail with "Nullable object must have a value"


I want to add in some more DataMembers to the WCF DataContract, without breaking existing clients. This is why I added them as nullable DateTime objects, however the clients fail with "Nullable object must have a value".

I understand this is something to do with DateTime? something = (DateTime?) null;. How can I make this work without having to change all the existing clients?


Solution

  • [DataMember(IsRequired = false)]