title: XmlDocument.Load(xml) generates No Root Element error from XmlSerializer serialized code
body: <p>I have a class like so:</p>
  
  <pre><code>[XmlRoot"MyMessageType")]
  public class MyMessageType : BaseMessageType
  {
      [XmlElement("MessageId")]
      //Property for MessageId
  
      ...
      &lt;snip&gt;
  
      //end properties.
  }
  </code></pre>
  
  <p>This class contains a static method to create an XmlDocument instance to pass to a BizTalk server.  Like so:</p>
  
  <pre><code>public static XmlDocument GetMyMessageType(string input1, string input2 ...)
  </code></pre>
  
  <p><code>GetMyMessageType</code> creates an instance of MyMessageType, then calls the following code:</p>
  
  <pre><code>XmlSerializer outSer = new XmlSerializer(instance.GetType());
  using (MemoryStream mem = new MemoryStream())
  using (XmlWriter _xWrite = XmlWriter.Create(mem))
  {
    outSer.Serialize(_xWrite, instance);
    XmlDocument outDoc = new XmlDocument();
    outDoc.Load(XmlReader.Create(mem));
    return outDoc;
  }
  </code></pre>
  
  <p>When I attempt to run this code, I receive an <code>XmlException</code> "The Root Element is Missing."  When I modify the code to output to a test file, I get a well-formed Xml document.  Can anyone tell me why I would be able to output to a file, but not as an XmlDocument?</p>