title: C# XML deserialization with namespace
body: <p>I have XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"&gt;
      &lt;gesmes:subject&gt;Reference rates&lt;/gesmes:subject&gt;
      &lt;gesmes:Sender&gt;
          &lt;gesmes:name&gt;European Central Bank&lt;/gesmes:name&gt;
      &lt;/gesmes:Sender&gt;
      &lt;Cube&gt;
          &lt;Cube time='2015-12-16'&gt;
              &lt;Cube currency='USD' rate='1.0933'/&gt;
              &lt;Cube currency='JPY' rate='133.18'/&gt;
          &lt;/Cube&gt;
      &lt;/Cube&gt;
  &lt;/gesmes:Envelope&gt;
  </code></pre>
  
  <p>which I'm trying to deserialize with:</p>
  
  <pre><code>[XmlRoot("Envelope", Namespace = EcbNameSpace)]
  public class EcbEnvelope
  {
      const string EcbNameSpace = "http://www.gesmes.org/xml/2002-08-01";
  
      [XmlElement("Sender", Namespace = EcbNameSpace)]
      public string EcbSender { get; set; }
  
      [XmlElement("subject", Namespace = EcbNameSpace)]
      public string EcbSubject { get; set; }
  
      [XmlArray("Cube")]
      [XmlArrayItem("Cube")]
      public List&lt;CubeRoot&gt; CubeRootEl { get; set; }
  
      public class CubeRoot
      {
          [XmlAttribute("time")]
          public string Time { get; set; }
  
          [XmlElement("Cube")]
          public List&lt;CubeItem&gt; CubeItems { get; set; }
  
          public class CubeItem
          {
              [XmlAttribute("rate")]
              public string RateStr { get; set; }
  
              [XmlIgnore]
              public decimal Rate
              {
                  get { return decimal.Parse(RateStr); }
              }
  
              [XmlAttribute("currency")]
              public string Currency { get; set; }
          }
      }   
  }
  </code></pre>
  
  <p>However, it deserializes CubeRootEl as empty list. If I remove namspaces from XML, then it deserializes successfully. What am I doing wrong? I tried adding empty namespaces to CubeRootEl in code, but also unsuccessfully.</p>
  
  <p>Here's the code used for deserialization:</p>
  
  <pre><code>var serializer = new XmlSerializer(typeof(EcbEnvelope)); 
  using (var streamReader = new StreamReader(pathToFile)) 
      var a = serializer.Deserialize(streamReader) as EcbEnvelope; 
  } 
  </code></pre>