0

I'm having a problem on a system that is running on IIS 10.0.14393.0 with Framework 4.6.1.

System.ArgumentOutOfRangeException: operation=159 Parameter name: operation

The number "159" is random, sometimes it is "0" or even very large "1380273440"

It's an intermittent problem, but I've noticed that the times it occurs are at peak usage times. The error stops when I recycle Connection Pooling within IIS.

  • Firebird 2.1
  • FirebirdSql.Data.FirebirdClient 6.6.0
  • Visual Studio 2022 - Version 17.1.3

I found some links, but I didn't have the solution for lack of more information. The problem is that the error cannot be reproduced in the development environment.

The error does not occur in the same place and also happens on different forms. I've already tried to reproduce the error in the development environment, but I couldn't.

Below is the code where it occurs most frequently:

protected void Page_Load(object sender, EventArgs e)
{
    if ((Session["NomeUsuario"] == null) || (Session["NomeSistema"].ToString() != Master.Sistema()))
    {
        Response.Redirect("login.aspx");
    }

    tag = Request.QueryString["tag"];

    if (!Page.IsPostBack)
    {
        ControleAcesso controleAcesso = new ControleAcesso();
        string formulario = System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath);
        if (controleAcesso.ValidaRotina(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), formulario.ToLower()) == false) { Response.Redirect("Menu.aspx?acesso=1"); }
        else
        {
            if (controleAcesso.ValidaOpcao(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), "incluir") == true) { butIncluir.Visible = true; } else { butIncluir.Visible = false; }
            if (controleAcesso.ValidaOpcao(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), "alterar") == true) { griPadrao.Columns[0].Visible = true; } else { griPadrao.Columns[0].Visible = false; }
            if (controleAcesso.ValidaOpcao(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), "filhos") == true) { griPadrao.Columns[1].Visible = true; } else { griPadrao.Columns[1].Visible = false; }
            if (controleAcesso.ValidaOpcao(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), "excluir") == true) { griPadrao.Columns[2].Visible = true; } else { griPadrao.Columns[2].Visible = false; }
            if (controleAcesso.ValidaOpcao(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), "perfil") == true) { griPadrao.Columns[3].Visible = true; } else { griPadrao.Columns[3].Visible = false; }
            if (controleAcesso.ValidaOpcao(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), "historico-log") == true) { griPadrao.Columns[4].Visible = true; } else { griPadrao.Columns[4].Visible = false; }
            if (controleAcesso.ValidaOpcao(Session["NomeSistema"].ToString(), Session["NomeUsuario"].ToString(), "listagem") == true) { tabListagem.Enabled = true; } else { tabListagem.Enabled = false; }
        }

        hypRaca.ImageUrl = "~/Imagens/pastafechada.png";
        hypPai.ImageUrl = "~/Imagens/pastafechada.png";
        hypMae.ImageUrl = "~/Imagens/pastafechada.png";
        hypPaiPermanente.ImageUrl = "~/Imagens/dna_nao.png";
        hypMaePermanente.ImageUrl = "~/Imagens/dna_nao.png";
        txtMae.Attributes.Add("onfocus", "this.select()");
        txtPai.Attributes.Add("onfocus", "this.select()");
        tabManutencao.Enabled = false;
        tabPerfilGeral.Enabled = false;
        tabLogHistorico.Enabled = false;
        tabFilhos.Enabled = false;
        tabListagem.Enabled = false;
        txtCadastro.Text = DateTime.Today.ToShortDateString();
        tabCadastro.ActiveTabIndex = 0;
        tabPerfilLinhagemCelular.Enabled = false;
    }
}

public bool ValidaRotina(string sistema, string usuario, string formulario)
{
    using (FbConnection conexao = new FbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Dados"].ToString()))
        try
        {
            FbCommand comando = new FbCommand("select count(1) from SYS_PERMISSAO where SISTEMA=@SISTEMA and USUARIO=@USUARIO and FORMULARIO=@FORMULARIO and ((OPCAO is null) or (OPCAO=''))", conexao);
            comando.Parameters.Add("@SISTEMA", FbDbType.VarChar);
            comando.Parameters.Add("@USUARIO", FbDbType.VarChar);
            comando.Parameters.Add("@FORMULARIO", FbDbType.VarChar);
            comando.Parameters[0].Value = sistema;
            comando.Parameters[1].Value = usuario;
            comando.Parameters[2].Value = formulario.ToLower();
            conexao.Open();
            return !(((int)comando.ExecuteScalar()) > 0);
        }
        catch (Exception erro)
        {
            return false;
        }
        finally
        {
            conexao.Close();
        }
}

public bool ValidaOpcao(string sistema, string usuario, string opcao)
{
    using (FbConnection conexao = new FbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Dados"].ToString()))
        try
        {
            string formulario = System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath);

            FbCommand comando = new FbCommand("select count(1) from SYS_PERMISSAO where SISTEMA=@SISTEMA and USUARIO=@USUARIO and FORMULARIO=@FORMULARIO and OPCAO=@OPCAO", conexao);
            comando.Parameters.Add("@SISTEMA", FbDbType.VarChar);
            comando.Parameters.Add("@USUARIO", FbDbType.VarChar);
            comando.Parameters.Add("@FORMULARIO", FbDbType.VarChar);
            comando.Parameters.Add("@OPCAO", FbDbType.VarChar);
            comando.Parameters[0].Value = sistema;
            comando.Parameters[1].Value = usuario;
            comando.Parameters[2].Value = formulario.ToLower();
            comando.Parameters[3].Value = opcao.ToLower();
            conexao.Open();
            return !(((int)comando.ExecuteScalar()) > 0);
        }
        catch (Exception erro)
        {
            return false;                
        }
        finally
        {
            conexao.Close();
        }
}
  • Erro https://netnucleo.com.br/netdna/erro01.png – Osvaldo G. Da Cruz Júnior Jun 21 '22 at 17:38
  • Please post the full exception stacktrace, and the necessary steps to reproduce. Likely this is a bug in the driver, where it reads the wrong number of bytes somewhere when decoding the protocol, and then ends up reading an unexpected value at a later time. These types of bugs are sometimes really hard to pin down without having an exact reproduction script. As an aside, as it stands, your question is not really a good fit for Stack Overflow. I recommend asking about this on [firebird-net-provider Google Group](https://groups.google.com/g/firebird-net-provider). – Mark Rotteveel Jun 22 '22 at 06:33
  • I put a connection monitor with the Firebird database (FBMon.exe - Cantu) and managed to identify that connections were getting stuck in a query that returned more than 100,000 records. I fixed the SQL limiting the number of records returned and the error disappeared. – Osvaldo G. Da Cruz Júnior Jul 07 '22 at 13:20

0 Answers0