title: Trouble using XmlSerializer on a class: Object type not primitive
body: <p>I'm getting this error when trying to serialize a class: "There was an error generating the XML document. The type of the argument object  is not primitive."</p>
  
  <pre><code>public class TaskData
  {
      [XmlAttribute("Date")]
      public DateTime Date;
  
      public string Summary;
      public string Task;
      public int Priority; //1 Next, 2 Today, 3 This week, 4 This month, 5 This year.
      public bool InProgress;
  
      public TaskData() {}
  
      public TaskData(DateTime date, string summary, string task, int priority, bool inprogress)
      {
          Date = date;
          Summary = summary;
          Task = task;
          Priority = priority;
          InProgress = inprogress;
      }
  }
  
  public class Tasks
  {
      [XmlArray("Tasks")]
      public List&lt;TaskData&gt; tasks;
  
      public Tasks(){tasks = new List&lt;TaskData&gt;();}
  }
  
      static internal void Save(Tasks task)
      {
          string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
          Save(task, Path.Combine(path, "tasks.xml"));
      }
  
      static private void Save(Tasks task, string path)
      {
          XmlSerializer serializer = new XmlSerializer(typeof(TaskData));
          TextWriter writer = new StreamWriter(path);
          serializer.Serialize(writer, task);
          writer.Close();
      }
  </code></pre>
  
  <p>Does anyone see my mistake? I'm not sure what is causing the error. I'm writing this in Mono 2.10. The Save functions are in another class (which you can't see in the code here).</p>