Duplicate:
Omitting all xml namespaces when serializing an object? Not the same.. I want in the other way: Deserialize!
I have a C# class as bellow:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.portalfiscal.inf.br/nfe")]
[System.Xml.Serialization.XmlRootAttribute("NFe", Namespace = "http://www.portalfiscal.inf.br/nfe", IsNullable = false)]
public partial class TNFe
{
    private TNFeInfNFe infNFeField;
    private SignatureType signatureField;
    /// <remarks/>
    public TNFeInfNFe infNFe
    { ...
I use this class to serialize/deserialize XML files by user request. But I've got a problem: namespaces definition were added on the new version of this software. The XML is still the same, only adding namespaces definition.
Eg., last version...
<?xml version="1.0" encoding="utf-8" ?>
  <NFe>
    <infNFe version="1.10">
      ...
and new version...
<?xml version="1.0" encoding="utf-8" ?> 
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
    <infNFe version="2.10">
      ...
I need to load XML files with and without these namespaces. I have a lot of nested classes and each of it has its own namespaces definition.
I would like to use the same classes for both XML, with and without namespaces.
I tried to create an XmlTextReader and overwrite the NamespaceURI method, but I still receives an exception with no much info. I think .NET engine is trying to force the class namespace definition against the XML.
 
     
     
     
     
    