title: How to serialize nullable DateTime in a WCF DataContract?
body: <p>I am having trouble serializing this thing. </p>
  
  <pre><code>namespace Such.Namespace.Wow
  {
      [DataContract(Namespace = "http://very.namespace.uh")]
      public class DogeResponse
      {
          [DataMember]
          public virtual int Foo { get; set; }
  
          [DataMember]
          public virtual DateTime? ExpiringDate { get; set; }
      }
  }
  </code></pre>
  
  <p>In generated WSDL :  </p>
  
  <pre><code>&lt;xs:complexType name="DogeResponse"&gt;  
  &lt;xs:sequence&gt;
  &lt;xs:element minOccurs="0" name="Foo" type="xs:int"/&gt;  
  &lt;xs:element minOccurs="0" name="ExpiringDate" nillable="true" type="xs:dateTime"/&gt;  
  &lt;/xs:sequence&gt;&lt;/xs:complexType&gt;
  </code></pre>
  
  <p>But the run-time exception occurs and returns as XML fault: </p>
  
  <pre><code>&lt;SerializationException&gt;
  &lt;Message&gt;ValueType 'System.DateTime' cannot be null.&lt;/Message&gt;
  </code></pre>
  
  <p>Yes I saw a "similar" question but it was about ASMX service in somewhat older .NET.</p>
  
  <p>I wonder how to do it in .NET 4.5 WCF service?</p>