title: I can't serialize a list of objects in C# with XmlSerializer
body: <p>I have a list of many test implements the interface IDoTest, that I want to store in a file. I also want to read from this file. </p>
  
  <p>It seemed natural to simple use the <strong>XmlSerializer</strong> to store the objects in my List of IDoTest. But when I do this I get a vague  I am sorry I cant do that error in the neighborhood of  System.Xml.Serialization.TypeDesc.CheckSupported()</p>
  
  <p>Can the XmlSerializer only do trivial jobs? Or am I missing something? They are talking about <a href="http://msdn.microsoft.com/en-us/library/ms233843.aspx" rel="nofollow">custom serialization</a> at MSDN. 
  Here is my simplified code example.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Xml.Serialization;
  
  namespace ConsoleApplication1
  {
      public interface IDoTest
      {
          void DoTest();
          void Setup();
      }
      internal class TestDBConnection : IDoTest
      {
          public string DBName;
          public void DoTest()
          {
              Console.WriteLine("DoHardComplicated Test");
          }
          public void Setup()
          {
              Console.WriteLine("SetUpDBTest");
          }
      }
      internal class PingTest : IDoTest
      {
          public string ServerName;
          public void DoTest()
          {
              Console.WriteLine("MaybeDoAPing");
          }
          public void Setup()
          {
              Console.WriteLine("SetupAPingTest");
          }
      }     
  
      internal class Program
      {
          private static void Main(string[] args)
          {
  
              TestDBConnection Do1 = new TestDBConnection { DBName = "SQLDB" };
              PingTest Do2 = new PingTest { ServerName = "AccTestServ_5" };
              List&lt;IDoTest&gt; allTest = new List&lt;IDoTest&gt; { Do1, (Do2) };
              // Now I want to serialize my list. 
              // Its here where I get the error at allTest
              XmlSerializer x = new XmlSerializer(allTest.GetType());
              StreamWriter writer = new StreamWriter("mySerializedTestSuite.xml");
              x.Serialize(writer, allTest); 
  
          }
      }
  }
  </code></pre>