title: Child Xml Element is not Deserializing
body: <p><strong>The Problem</strong></p>
  
  <p>I have an issue when I deserialize my xml, one of the child elements is not being deserialized.  It is null in the class instance despite being populated in the xml.  </p>
  
  <p><strong>A little Background</strong></p>
  
  <p>I used <a href="http://www.windevpowertools.com/tools/106" rel="nofollow noreferrer">XsdObjectGenerator</a> to create poco classes based on my .xsd.   I was then able to deserialize the xml into a class instance and work with the objects.   </p>
  
  <p>I modifed the autogenerated classes by wrapping them in a namespace called 'TFS'.  </p>
  
  <p>At a certain point in the project, I found it necessary to place one of the child elements in it's own namespace called 'COM'.</p>
  
  <p>The next time I attempted to deserialized the xml into a class instance, the child element is not being deserialized.  </p>
  
  <p>Here is the pertinent snippet of TFS class code with the child element namespace changed to COM.  It also includes the parent element OrdDtl which remains in the TFS namespace.  </p>
  
  <pre><code>[XmlRoot(ElementName="OrdDtl",Namespace=Declarations.SchemaVersion,IsNullable=false),Serializable]
      public class OrdDtl
      {
              [XmlElement(Type=typeof(COM.AcctSetup), ElementName="AcctSetup", IsNullable=false, Form=XmlSchemaForm.Qualified, Namespace = Declarations.SchemaVersion)]
          [EditorBrowsable(EditorBrowsableState.Advanced)]
              public COM.AcctSetup __AcctSetup;
  
          [XmlIgnore]
              public COM.AcctSetup AcctSetup
          {
              get
              {
                  if (__AcctSetup == null) __AcctSetup = new COM.AcctSetup();     
                  return __AcctSetup;
              }
              set {__AcctSetup = value;}
          }
  </code></pre>
  
  <p>Here is the AcctSetup declaration in the COM namespace which is contained in it's own file:</p>
  
  <pre><code>[XmlRoot(ElementName = "AcctSetup", Namespace = Declarations.SchemaVersion, IsNullable = false), Serializable]
      public class AcctSetup
      {
  ......
  }
  </code></pre>
  
  <p>and here is my deserialize function:</p>
  
  <pre><code>public static T XMLStringToXMLObject&lt;T&gt;(string pXmlString)
      {
          T retVal = default(T);   
  
          try
          {
              XmlSerializer vSerializer = new XmlSerializer(typeof(T));
              MemoryStream vMemoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlString));
              XmlTextWriter vXmlTextWriter = new XmlTextWriter(vMemoryStream, Encoding.UTF8);
              retVal = (T)vSerializer.Deserialize(vMemoryStream);
          }
          catch (System.Exception ex)
          {
              if (ExceptionMain.LogException(ex))
                  throw;
          }
  
          return retVal;
      }
  </code></pre>
  
  <p>Any assistance in getting the COM.AcctSetup element to deserialize is very much appreciated.  Let me know if you need additional info or code samples.  </p>