title: Problem with a conversion of a complexType FROM object TO XML
body: <p>For those that like to resolve problems, here's a big one :P</p>
  
  <p>Well, I am developing a system using web services, where I send and receive XML as parameter (not normal parameters as Int, String, bool, etc).</p>
  
  <p>After I receive a XML, I validate the XML with the XSD and also I convert that to an object.. after the process I also convert that object to an XML (validated by XSD) and return as answer of my request of the WS.</p>
  
  <p>Well, my problem: I have complexType that I need to convert it using reflection, but, I am getting problem that I've never saw before.</p>
  
  <p><strong>My XSD is:</strong></p>
  
  <pre><code>  &lt;xsd:element name="EnviarLoteRpsResposta"&gt;
      &lt;xsd:complexType&gt;
        &lt;xsd:choice&gt;
          &lt;xsd:sequence&gt;
            &lt;xsd:element name="NumeroLote" type="tsNumeroLote" minOccurs="1" maxOccurs="1"/&gt;
            &lt;xsd:element name="DataRecebimento" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/&gt;
            &lt;xsd:element name="Protocolo" type="tsNumeroProtocolo" minOccurs="1" maxOccurs="1"/&gt;
          &lt;/xsd:sequence&gt;
          &lt;xsd:element ref="ListaMensagemRetorno" minOccurs="1" maxOccurs="1"/&gt;
        &lt;/xsd:choice&gt;
      &lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
  </code></pre>
  
  <p><strong>My class (normal class with GETs and SETs):</strong></p>
  
  <pre><code>    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
      [System.SerializableAttribute()]
      [System.Diagnostics.DebuggerStepThroughAttribute()]
      [System.ComponentModel.DesignerCategoryAttribute("code")]
      [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd")]
      [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd", IsNullable = false)]
      public class EnviarLoteRpsResposta
      {
  
          private object[] itemsField;
  
          private ItemsChoiceType[] itemsElementNameField;
  
          /// &lt;remarks/&gt;
          [System.Xml.Serialization.XmlElementAttribute("DataRecebimento", typeof(System.DateTime))]
          [System.Xml.Serialization.XmlElementAttribute("ListaMensagemRetorno", typeof(ListaMensagemRetorno))]
          [System.Xml.Serialization.XmlElementAttribute("NumeroLote", typeof(string), DataType = "nonNegativeInteger")]
          [System.Xml.Serialization.XmlElementAttribute("Protocolo", typeof(string))]
          [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
          public object[] Items
          {
              get
              {
                  return this.itemsField;
              }
              set
              {
                  this.itemsField = value;
              }
          }
  
          /// &lt;remarks/&gt;
          [System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
          [System.Xml.Serialization.XmlIgnoreAttribute()]
          public ItemsChoiceType[] ItemsElementName
          {
              get
              {
                  return this.itemsElementNameField;
              }
              set
              {
                  this.itemsElementNameField = value;
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>How am I using this class?:</strong></p>
  
  <pre><code>EnviarLoteRpsResposta enviarLoteRpsResposta = new EnviarLoteRpsResposta();
  enviarLoteRpsResposta.Items = new object[1];
                  enviarLoteRpsResposta.Items[0] = DateTime.Now;
  
                  enviarLoteRpsResposta.ItemsElementName = new ItemsChoiceType[1];
                  enviarLoteRpsResposta.ItemsElementName[0] = ItemsChoiceType.DataRecebimento;
  </code></pre>
  
  <p>My error happens when I try convert this object to a XML:
  XmlSerializer xs = new XmlSerializer(enviarLoteRpsResposta.GetType());</p>
  
  <p>My error: There was an error reflecting type 'NFSEWS.Models.Bean.EnviarLoteRpsResposta'.</p>
  
  <p>I don't know what do I can do to resolve this..</p>