title: C# Web Service XmlSerializer issue
body: <p>I have a C# Web Service that is serializing my simple class:</p>
  
  <pre><code>    [Serializable]
      [XmlInclude(typeof(Bitmap))]
      [XmlTypeAttribute(Namespace = "http://tempuri.org/")]
      public class Class1 
      {
          private static Bitmap _myImage = new Bitmap(@"C:\WebApplication1\ClassLibrary1\Untitled.png");
  
  
          public Bitmap MyImage
          {
              get { return _myImage; }
  
              set
              {
                  _myImage = value;
              }
          }
      }
  </code></pre>
  
  <p>Here's the asmx.cs code that does the serialization:</p>
  
  <pre><code>[WebMethod]
  public string HelloWorld()
  {
      var c = new Class1();
      XmlSerializer serializer = new XmlSerializer(typeof(Class1));
  
      return XMLSerializer(c);
  }
  
  public string XMLSerializer(object pObject)
  {
      try
      {
          XmlSerializer xs = new XmlSerializer(pObject.GetType());
          using (StringWriter stream = new StringWriter())
          {
              xs.Serialize(stream, pObject);
              stream.Flush();
              return stream.ToString();
          }
      }
      catch (Exception ex)
      {
          return ex.ToString();
      }
  
  }
  </code></pre>
  
  <p>Looks prety straight forward.  However, the XML generated by the XmlSerializer is producing and error when I try to DeSerialize it.  </p>
  
  <pre><code>{"There is an error in XML document (5, 5)."}
  {"Parameter is not valid."}
  </code></pre>
  
  <p>When I try to load the generated XML into IE I get this error.</p>
  
  <pre><code>Switch from current encoding to specified encoding not supported. Error processing resource 'file:///C:/Users/mhall15/Deskt...
  
  &lt;?xml version="1.0" encoding="utf-16"?&gt;
  </code></pre>
  
  <p>Here's the generated XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;Class1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;MyImage xmlns="http://tempuri.org/"&gt;
      &lt;Palette /&gt;
    &lt;/MyImage&gt;
  &lt;/Class1&gt;
  </code></pre>
  
  <p>Any ideas what's going on?</p>