Spring V10 - Error in Abreempresa

Asked

Viewed 363 times

1

When I try to open the company using the Abreempresa method, I get the following error

'Object reference is not defined as an instance of an object.'

Does anyone know how to solve ? Thank you.

The code I use is this:

  Public bsERP As New ErpBS
    Public plat As New StdPlatBS

    Public p_empresa As String = "DEMO"
    Public p_username As String = "naurio"
    Public p_password As String = "*****"
    Public p_instancia As String = "Default"
    Public p_versao As String = "10.00"
    Public p_plat As String = "EMPRE"

 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim tp As EnumTipoPlataforma = EnumTipoPlataforma.tpProfissional
        If p_plat = "EMPRE" Then
            tp = EnumTipoPlataforma.tpEmpresarial
        ElseIf p_plat = "ERPPLAT" Then
            tp = EnumTipoPlataforma.tpFirst
        End If
        Dim objStdTransac As StdBETransaccao = New StdBETransaccao()

        'ABRE a plataforma para integrar os anexos
        Dim confapl As New StdBSConfApl
        Dim trans As New StdBETransaccao
        With confapl
            .AbvtApl = "ERP"
            .Instancia = p_instancia
            .Utilizador = p_username
            .PwdUtilizador = p_password
            .LicVersaoMinima = p_versao
        End With
        plat.AbrePlataformaEmpresa(p_empresa, trans, confapl, tp)

        bsERP.AbreEmpresaTrabalho(tp, p_empresa, p_username, p_password, objStdTransac, p_instancia)


        '*************************************************************

        If Convert.ToBoolean(bsERP.Base.Clientes.NumeroContribuintesRepetidos("000000000")) Then
            MessageBox.Show("Cannot continue because the NIF for the current entity already exist.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        Else
            Dim customer As BasBECliente = New BasBECliente()
            customer.Nome = "naurio"
            customer.Cliente = "nau"
            customer.NumContribuinte = "000000000"
            customer.Moeda = "EUR"
            'customer.EmModoEdicao = If(PriEngine.Engine.Base.Clientes.Existe(txtName.Text), True, False)

            Try
                bsERP.Base.Clientes.Actualiza(customer)
            Catch ex As Exception
                MessageBox.Show("Unable to save client. " & vbLf & ex.Message)
            End Try
        End If




        '***********************************************************************


        bsERP.FechaEmpresaTrabalho()
        bsERP.FechaLigacaoBaseDados()

If you can help me solve or an example of using the engines in visual studio on Asp.net. Thank you.

1 answer

0


If I understand correctly, you are making a web application. If so, I recommend that you do not use the API directly in your application, and the answer is simple. A web application is an application stateless app which means that every request you make you have to authenticate yourself and do the AbreEmpresa, that we say is something that has a remarkable performance cost.

Solutions:

  • Using the webapi instead of the api.
  • Create your web services that deposit information in a queue and then use a background worker to access the API. This yes can instantiate and keep in memory the instance.

As for your particular problem. What’s going on is that you don’t have all the assemblies you need published in the BIN folder of your webapp. When you use ERPBS100 you will need to have all assemblies that make up the API in that same folder. To solve this you have to use an Assembly resolve, here you can see how Assembly resolving in ASP.NET

  • Thank you so much for the help, I understood what was explained and made sense to me to complement the work. But I have another question. I went to Github I used your Exmplos that are developed in C# and work perfectly, but to work in VB.NET the procedure is the same ? I tried to use the same procedure of C# converting the code but I get the same error as this above mentioned.

  • In VB.net you may have to adapt the solve, except it should work without problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.