Error in DANFe procedure! [- 2146233036] The type initializer for 'Module' threw an exception

0

Good afternoon, I have a system that prints DANFEs in vb.net , but in a specific client it is giving the following error:

  

DANFe procedure error! [- 2146233036] The type initializer for threw an exception

I took a close look at the code and got to the following function:

 Protected Overrides Sub ImprimeCabecalho()
   Dim empRz As System.String = Configuracoes4.Empresa.Razao
   Dim empCNPJ As System.String = Configuracoes4.Empresa.CNPJ
   Dim empIE As System.String = Configuracoes4.Empresa.Fisco.IE
   Dim empEndereco As System.String = Configuracoes4.Empresa.Contato.Endereco
   Dim empNumero As System.String = Configuracoes4.Empresa.Contato.Numero
   Dim empBairro As System.String = Configuracoes4.Empresa.Contato.Bairro
   Dim empCidade As System.String = Configuracoes4.Empresa.Contato.Cidade
   Dim empUF As System.String = Configuracoes4.Empresa.UF
   Dim empCEP As System.String = Configuracoes4.Empresa.Contato.CEP
   Dim empTelefone As System.String = Configuracoes4.Empresa.Contato.Telefone

   Dim str As String = ""

   If Not Me.FontesDefinidas Then
      Me.DefineFontes()
   End If

 'Cabeçalho principal
   str += empRz + vbLf
   str += "CNPJ:" & empCNPJ & " IE:" & empIE + vbLf
   str += empEndereco & ", " & empNumero & " " & empBairro & "-" & empCidade & "/" & empUF + vbLf
  str += "CEP:" & empCEP & " Tel:" & empTelefone

MsgBox("1")

  Me.ImprimeSpoolerCentro2(str)

  Me.ImprimeSpoolerCentro(RetornaLinha("-", False))
'Informativo NFCe
  str = "DANFE NFC-e - Documento Auxiliar da Nota Fiscal Eletrônica para Consumidor Final" & vbLf
  If Configuracoes4.Empresa.UF <> "PR" Then
      str += "Não permite aproveitamento de crédito de ICMS"
  End If
  Me.ImprimeSpoolerCentro(str, FonteOpcao.Destaque)
End Sub

In this function I have a msgbox that is fired before the function Me.ImprimeSpoolerCentro2 , which receives a string as a parameter, debugging the project the string is normally formatted, below the function PrintSpoolerCentro:

Protected Sub ImprimeSpoolerCentro2(text As String)
    MsgBox("2")
    Me.ImprimeSpooler(text, , Nothing, Nothing, Windows.HorizontalAlignment.Center, )
    MsgBox("3")
End Sub

The error is triggered exactly when the function is called, not even displaying the MsgBox with "2".

Does anyone have an idea of what it might be?

    
asked by anonymous 30.10.2018 / 20:17

1 answer

0
The problem I found here was that the version of .NET installed on my client's machine was version 4.7 installed on an updated windows 7 SP1, I downloaded the version to 4.6 and it worked perfectly, but until I realized this, there was already past 2 or 3 days. This is personal, I just wanted to share the resolution with everyone.

    
20.11.2018 / 17:32