title: Is good practice to throw exceptions in a property with DataMember attribute applied?
body: <p><code>DataContract</code> and <code>DataMember</code> attributes may be also used in order to serialize an object to file and for deserialization, by using a <code>DataContractSerializer</code>. Suppose we have a class with the following private field and public property.</p>
  
  <pre><code>public class MyClass
  {
      private int positiveValue;
  
      public int PositiveValue
      {
          get { return positiveValue; }
          set
          {
              if (value &lt; 1)
                  throw new ArgumentOutOfBoundException(...);
              positiveValue = value;
          }
      }
  }
  </code></pre>
  
  <p>Now suppose we have an XML file containing the state of a previously serialized object, and assume that the user has modified this file, specifying an incorrect value (that is a non positive value) for the <code>PositiveValue</code> property. During deserialization an exception would be thrown, since the value in the file is invalid.</p>
  
  <p>Suppose we want to deserialize a list of <code>MyClass</code> objects from a file: if some object is not valid, an exception is thrown. Is it possible to make sure that the <code>DataContractSerializer</code> ignores invalid objects? Moreover, taking into account the problem just explained, is good practice to throw exceptions in a property with DataMember attribute applied?</p>