title: Serialization Exception : data contract is not expected
body: <p>I receive the following exception message while serializing an object to XML:</p>
  
  <pre><code>{"Type 'Alerter.EmailSender' with data contract name  'EmailSender:http://schemas.datacontract.org/2004/07/Alerter' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer."}
  </code></pre>
  
  <p>This is the class that i am trying to serialize an object of it to an XML File:</p>
  
  <pre><code>namespace Alerter
  {
    [DataContract]
    public class EmailSender : IAction
    {
      private EmailSetting _emailSetting;
      private SmtpClient _smtpClient;
      [DataMember]
      public bool IncludeFullDetails
      {
          get;
          set;
      }
      [DataMember]
      public string[] Receivers
      {
          get;
          set;
      }
  
      public EmailSender()
      {
          _emailSetting = new EmailSetting();
          SetupClient();
      }
  
      private void SetupClient()
      {
          // Some Logic
      }
  
  
      public void Report(LogDictionary logDictionary)
      {
         // Some Logic
      }
     }
   }
  </code></pre>
  
  <p>That's the code i use for serialization:</p>
  
  <pre><code> using (FileStream writer = new FileStream(fileName, FileMode.Create))
          {
              DataContractSerializer ser =
                  new DataContractSerializer(typeof(List&lt;Rule&gt;));
              ser.WriteObject(writer, list);
          }
  </code></pre>
  
  <p>I appreciate your help.</p>