title: Why XmlSerializer adding garbage value to end tag of the root element?
body: <p>I am trying to write the value to xml values using the XmlSerializer and below is the code. The code will be called on the selection change of the dropdown list. So for the first time it works fine but for the second selection change event it inserts the garbage value like the xml shown below.</p>
  
  <pre><code>protected void UpdateDefaultReasonConfig(object sender, EventArgs e)
      {
          string configFile = ConfigurationSettings.AppSettings["DefaultOutageReasonConfig"];
  
          DefaultOutageReason defaultOutageReason = new DefaultOutageReason();
          defaultOutageReason.OutageReason = this._defaultOutageReason.Text;
          XmlSerializer writer = new XmlSerializer(typeof(DefaultOutageReason));
          using (FileStream write = File.OpenWrite(configFile))
          {
              writer.Serialize(write, defaultOutageReason);
          }
      }
  </code></pre>
  
  <p>And the resulting xml is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;DefaultOutageReason xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;OutageReason&gt;Storm Damage&lt;/OutageReason&gt;
  &lt;/DefaultOutageReason&gt;eason&gt;
  </code></pre>
  
  <p>So please help me why it adding this extra value to the end tag of the root.</p>