error with windows forms

Asked

Viewed 142 times

1

Created an application, on my pc runs normally, but on the client’s pc presents the following problems:

inserir a descrição da imagem aqui

here the full description:

Assinatura do problema:
  Nome do Evento de Problema:   CLR20r3
  Assinatura do Problema 01:    PowerBot.exe
  Assinatura do Problema 02:    1.0.0.0
  Assinatura do Problema 03:    c7a551c5
  Assinatura do Problema 04:    PowerBot
  Assinatura do Problema 05:    1.0.0.0
  Assinatura do Problema 06:    c7a551c5
  Assinatura do Problema 07:    64
  Assinatura do Problema 08:    3b2
  Assinatura do Problema 09:    System.NullReferenceException
  Versão do sistema operacional:    6.1.7601.2.1.0.256.1
  Identificação da Localidade:  1046
  Informações Adicionais 1: 0a9e
  Informações Adicionais 2: 0a9e372d3b4ad19135b953a78882e789
  Informações Adicionais 3: 0a9e
  Informações Adicionais 4: 0a9e372d3b4ad19135b953a78882e789

looking at windows logs, I found a log that relates to a thread: inserir a descrição da imagem aqui

These are the methods: this Aki is on a timer:

 private void timerUsoContinuo_Tick(object sender, EventArgs e)
    {
        Thread tGetUsoContinuo = new Thread(getUsoContinuo);
        tGetUsoContinuo.Start();
    }



 private void getUsoContinuo()
    {
        if (condição 01){}

        else if (arquivoLido.banco.ToLower().Contains("sistema"))
        {
            GetDadosSistema.getUsoContinuoSistema(arquivoLido);
        }
    }

public static void getUsoContinuoSistema(Dados dados)
    {            
        StringBuilder sb = null;
        try
        {
            using (var context = new Contexto(Sistema.ConectionSistema.conexaoSistema(dados.host, dados.banco, dados.usuario, dados.senha)))
            {
                Empresa emp = Services.VendaService.GetEmpresa(dados.cnpj);

                if (emp.status_servvico != 0)
                {
                    if (emp != null)
                    {
                        string command = " SELECT " +
                                " fpc.fpc_pedido AS seq," +
                                " cli.cli_cpf_cnpj AS cpf_cliente," +
                                " cli.cli_nome AS nome_cliente," +
                                " pro.cad_cod_barra AS cod_barras," +
                                " CONCAT(pro.cad_descricao, ' ', pro.cad_apresentacao) AS nome_produto, " +
                                "  fpc.fpc_qtde AS qtde_compra, " +
                                " fpc.fpc_dt_emissao AS data_compra," +
                                " fpc.fpc_dt_termino AS data_prox_compra" +
                                " FROM estfpc fpc" +
                                " INNER JOIN cadcli cli ON cli.cli_codigo = fpc.fpc_cod_cliente" +
                                " INNER JOIN estcad pro ON pro.cad_codigo = fpc_produto" +
                                " WHERE fpc.fpc_dt_emissao >= " + dados.dataPartida.ToString("yyyy/MM/dd") +
                                " AND fpc.fpc_fg = " + dados.filial +
                                " AND fpc.fpc_dt_termino IS NOT NULL" +
                                " AND cli.cli_cpf_cnpj != ''" +
                                " AND fpc.fpc_pedido >=" + emp.ult_continuo +
                                " ORDER BY fpc.fpc_pedido" +
                                " LIMIT 100";

                        #region MyRegion
                        MySqlConnection conn = new MySqlConnection("server = " + dados.host + "; port = 3306; database = " + dados.banco + "; uid = " + dados.usuario + "; password = " + dados.senha + "; SslMode = none; charset = utf8; Allow Zero Datetime = true; Connection Timeout = 950");

                        conn.Open();
                        string checkuser = command;
                        MySqlCommand cmd = new MySqlCommand(checkuser, conn);
                        MySqlDataReader reader;
                        reader = cmd.ExecuteReader();

                        #endregion

                        List<UsoContinuoAux> lstUsoContinuo = new List<UsoContinuoAux>();

                        while (reader.Read())
                        {
                            UsoContinuoAux newUso = new UsoContinuoAux();

                            newUso.seq = Convert.ToInt32(reader[0]);
                            newUso.cpf_cliente = reader[1].ToString();
                            newUso.nome_cliente = reader[2].ToString();
                            newUso.cod_barras = reader[3].ToString();
                            newUso.nome_produto = reader[4].ToString();
                            newUso.qtde_compra = Convert.ToInt16(reader[5]);
                            newUso.data_compra = Convert.ToDateTime(reader[6]);
                            newUso.data_prox_compra = Convert.ToDateTime(reader[7]);

                            newUso.cnpj_farmacia = dados.cnpj;

                            lstUsoContinuo.Add(newUso);

                        }
                        conn.Close();

                        if (lstUsoContinuo.Count > 0)
                            //Services.VendaService.SalvarUsoContinuo(lstUsoContinuo, dados.cnpj);
                            Services.VendaService.SalvarUsoContinuo(lstUsoContinuo);
                    }
                }
            }
        }
        catch (Exception erro)
        {
            GeraLogError.GeraLog("GetDadosSistema", MethodBase.GetCurrentMethod().Name, erro.Message, sb.ToString());
        }
    }

someone knows what may be happening?

  • 2

    Missing initialize some variable, is occurring the exception System.NullReferenceException. Debugga and tells which part the error is occurring.

  • problem is q on my machine, and on another pc does not occur error, works round.

  • I guess the error occurs in this part arquivoLido.banco.ToLower().Contains("sistema"), by name the variable reads some file, probably there is this file for her to read on the machine she is testing. But the correct thing is to initialize the variable so that the exception no longer occurs.

  • put Aki system, to take out the real name, the name is another, despite that, works normally on my pc, has two more pcs q are ok. Worst q has no debug there in the customer, very strange.

  • In the method getUsoContinuo() is missing logical operator >;<;==;!= in the validation if (condição 01){} does it check? Or was it a mistake to pass the code here in the question? Because the error may be there.

  • The problem lies within the method getUsoContinuo(), in the error a Thread is referenced because you create a Thread in the method timerUsoContinuo_Tick() which implements the method getUsoContinuo().

  • was error to the necklace, already found the problem, a variable not instantiated, the variable Sb. Thank you all.

Show 2 more comments
No answers

Browser other questions tagged

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