XmlSerializer throws System.InvalidOperationException
<p>So basically I have 2 classes:</p>

<pre><code>public class Configuration
{
    public Configuration()
    {
        Sections = new List&lt;Section&gt;();
    }

    public List&lt;Section&gt; Sections { get; private set; }
}

public class Section : IXmlSerializable
{
    public string Name { get; set; }

    public XmlSchema GetSchema()
    {
        return null;
    }

    public void ReadXml(XmlReader reader)
    {
        Name = reader.GetAttribute("Name");
    }

    public void WriteXml(XmlWriter writer)
    {
        writer.WriteAttributeString("Name", Name);
    }
}
</code></pre>

<p>This code works well:</p>

<pre><code>var configuration = new Configuration();
configuration.Sections.Add(new Section {Name = "#Submitter.LoginTest"});
configuration.Sections.Add(new Section {Name = "Default"});

using (StreamWriter writer = new StreamWriter(@"d:\data.xml"))
{
    XmlSerializer x = new XmlSerializer(typeof(Configuration));
    x.Serialize(writer, configuration, XmlSerializerHelper.EmptyNamespaces);
}
</code></pre>

<p>Serialization result:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Configuration&gt;
  &lt;Sections&gt;
    &lt;Section Name="#Submitter.LoginTest" /&gt;
    &lt;Section Name="Default" /&gt;
  &lt;/Sections&gt;
&lt;/Configuration&gt;
</code></pre>

<p>But this code throws an Exception: An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll 
Additional information: There is an error in XML document (4, 6).</p>

<pre><code>var configuration = new Configuration();
using (StreamReader reader = new StreamReader(@"d:\data.xml"))
{
    XmlSerializer x = new XmlSerializer(typeof(Configuration));
    configuration = (Configuration) x.Deserialize(reader);
}
</code></pre>

<p>So for serialization of Section I can't use attribute-based serialization, but it works perfectly fine:</p>

<pre><code>public class Section
{    
    [XmlAttribute]
    public string Name { get; set; }
}
</code></pre>

<p><strong>UPD1</strong>:
Serialization/deserialization of Section as root works well</p>