The 'http://www.portalfisc.in.inf.br/nfe:TNFe' type is not declared

2

Good morning, I usually avoid asking questions here in the forum because I always find many answers that fill my situation.

I'm doing an integration with Sefaz, using the Authorization Ws of NFe 4.00, but when I do the validation of my XML the error is returned:

  

Type ' link ' is not declared

I created my project in Asp.Net Core (Web Api) and this is the code I use to validate:

XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.ValidationType = ValidationType.Schema;
xmlReaderSettings.Schemas = new XmlSchemaSet();
xmlReaderSettings.XmlResolver = new XmlUrlResolver() { Credentials = CredentialCache.DefaultCredentials };
xmlReaderSettings.Schemas.Add(null, localSchema);
xmlReaderSettings.ValidationEventHandler += new ValidationEventHandler(delegate (object sender, ValidationEventArgs e)
{
     var ex = new Exception(string.Format("Falha ao validar Xml! Linha: {0}, Coluna: {1}, Mensagem: {2}",
     e.Exception.LineNumber, e.Exception.LinePosition, e.Exception.Message));
     ex.Data.Add("statusCode", HttpStatusCode.BadRequest);
     throw ex;
 });

 using (var stringReader = new StringReader(xml.InnerXml))
 {
     var xmlReader = XmlReader.Create(stringReader, xmlReaderSettings);
     while (xmlReader.Read()) { }                    
     xmlReader.Close();

Remembering that:

  • The same code works on projects other than Core;
  • The error occurs in the following line "var xmlReader = XmlReader.Create (stringReader, xmlReaderSettings);"
  • All NFe 4.00 schemas are up to date;
  • I know the error is not in XML because it works quietly on a version of an old project;
  • I tried some tips from others that asked and did not work;
  • The schemas that I use, can be downloaded at the following link: " link "

Thanks for the help right away.

    
asked by anonymous 05.09.2018 / 14:37

0 answers