title: How can I specify DataContractSerializer EmitDefaultValue = false globally through app.config or web.config or some other means?
body: <p>I have a very large class library with &gt;100 POCO objects. I need to serialize these objects into XML to transmit to a REST service.</p>
  <p>I've been trying to use <code>DataContractSerializer</code>, but it outputs XML elements with <code>i:nil=&quot;true&quot;</code> for any properties that are null. This trips up the REST service to which I'm transmitting XML. Yes, I realize that it shouldn't. The service provider has informed me that correcting the issue will take months. I don't have months to wait for this service to work.</p>
  <p>I've been digging through the documentation trying to find a way to suppress these nil objects from being transmitted. I'm aware that I could set the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute.emitdefaultvalue(v=vs.110).aspx" rel="noreferrer">EmitDefaultValue property</a> to false on each individual property of each POCO object. I'm not about to do that for more than 100 objects unless I have no other choice. Furthermore, I don't believe I should be forced to annotate my class library objects with DataContract attributes. I also don't want to mirror my class library with DataContractSurrogates. That is just obscene.</p>
  <h2>Question</h2>
  <p>Surely, there is a configuration option somewhere where I can specify that the default behavior for serialization should be <code>EmitDefaultValue = false</code>. I've been unable to find it though. I'm hoping someone else has found it, or has found another global option for suppressing the null properties from the XML.</p>
  <ul>
  <li>Can this be specified in app.config/web.config?</li>
  <li>Or, can it be set on the <code>DataContractSerializer</code> instance?</li>
  </ul>
  <p>If this doesn't exist, it seems like a HUGE oversight by Microsoft.</p>