Skip to Content
0

Add-on 9000002 failed with exception; Event Type: 6

Apr 11 at 10:32 PM

74

avatar image

Hi experts, can someone of you help me.

When i'm in debug mode the add-on works fine, but then if i register the addon the menu and form loads normaly but when i click on a button to fill my grid i receive the message in status bar: Add-on 9000002 failed with exception; Event Type: 6

this is the code in the button

private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)

{

//throw new System.NotImplementedException();

cargarGrid(); //load grid

BubbleEvent = true;

}

Thanks in advance

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ricardo Benavides Apr 12 at 06:47 AM
0

Hi,

Can you post cargarGrid() code?

Show 3 Share
10 |10000 characters needed characters left characters exceeded

This is the code

        private void cargarGrid()
        { 
            if (this.Grid0.DataTable != null)
            {
                this.Grid0.DataTable = null;
                this.dt = null;
            }
            SetApplication();<br>
            //string for_date;
            //for_date = EditText0.Value;
            //string today_date_str;
            //today_date_str = (for_date.Substring(6, 2) + ("/"
            //            + (for_date.Substring(4, 2) + ("/" + for_date.Substring(0, 4)))));

            try
            {
                ///////////////////////////////Cargando datos a Grid///////////////////////////////////////
                oForm = (SAPbouiCOM.Form)Application.SBO_Application.Forms.ActiveForm;
                dt = oForm.DataSources.DataTables.Add("dt");
                dt.ExecuteQuery("select CardCode, Cardname, DocNum, DocTotal, U_Quedan, U_Status, U_Monto, U_Comments, U_Responsable, DocEntry, '' AS Guardar From OINV where DocDate = Convert(DateTime, '" + EditText0.Value + "', 112) AND U_Ruta = '" + EditText1.Value + "'  order by DocNum ASC");
                Grid0.DataTable = dt;
                dt = null;

                ////////////////////////////////Editando Columnas del Grid////////////////////////////////////////
                SAPbouiCOM.EditTextColumn oEditCol0;
                oEditCol0 = ((SAPbouiCOM.EditTextColumn)(Grid0.Columns.Item(0)));
                oEditCol0.LinkedObjectType = "2";
                oEditCol0.Width = 70;
                oEditCol0.Editable = false;

                SAPbouiCOM.EditTextColumn oEditCol1;
                oEditCol1 = ((SAPbouiCOM.EditTextColumn)(Grid0.Columns.Item(1)));
                oEditCol1.Width = 350;
                oEditCol1.Editable = false;

                SAPbouiCOM.EditTextColumn oEditCol2;
                oEditCol2 = ((SAPbouiCOM.EditTextColumn)(Grid0.Columns.Item(2)));
                oEditCol2.Editable = false;

                SAPbouiCOM.EditTextColumn oEditCol3;
                oEditCol3 = ((SAPbouiCOM.EditTextColumn)(Grid0.Columns.Item(3)));
                oEditCol3.Editable = false;

                SAPbouiCOM.EditTextColumn oEditCol9;
                oEditCol9 = ((SAPbouiCOM.EditTextColumn)(Grid0.Columns.Item(9)));
                oEditCol9.LinkedObjectType = "13";
                oEditCol9.Editable = false;

                SAPbouiCOM.EditTextColumn oEditCol6;
                oEditCol6 = ((SAPbouiCOM.EditTextColumn)(Grid0.Columns.Item(6)));
                oEditCol6.Visible = false;

                ////////////////////////////Cargando Combobox Responsable en datagrid////////////////////////////////////
                Grid0.Columns.Item("U_Responsable").Type = SAPbouiCOM.BoGridColumnType.gct_ComboBox;
                SAPbouiCOM.ComboBoxColumn oCBC = (SAPbouiCOM.ComboBoxColumn)Grid0.Columns.Item("U_Responsable");
                //oCBC.ExpandType = SAPbouiCOM.BoExpandType.et_DescriptionOnly; // para mostrar solo la descripcion
                SAPbobsCOM.Recordset oRec = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oRec.DoQuery("select Code, Name from [@MOTORISTAS_RUTAS]");

                oRec.MoveFirst();
                while (!oRec.EoF)
                {
                    oCBC.ValidValues.Add(oRec.Fields.Item(0).Value.ToString(), oRec.Fields.Item(1).Value.ToString());
                    oRec.MoveNext();
                }
                oCBC = null;

                ////////////////////////////Cargando Combobox U_Status en datagrid////////////////////////////////////
                Grid0.Columns.Item("U_Status").Type = SAPbouiCOM.BoGridColumnType.gct_ComboBox;
                oCBCST = (SAPbouiCOM.ComboBoxColumn)Grid0.Columns.Item("U_Status");
                //oCBC.ExpandType = SAPbouiCOM.BoExpandType.et_DescriptionOnly; // para mostrar solo la descripcion
                SAPbobsCOM.Recordset oRecST = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oRecST.DoQuery("select FldValue, Descr from UFD1 where FieldID = 41 and TableID = 'OINV'");

                oRecST.MoveFirst();
                while (!oRecST.EoF)
                {
                    oCBCST.ValidValues.Add(oRecST.Fields.Item(0).Value.ToString(), oRecST.Fields.Item(1).Value.ToString());
                    oRecST.MoveNext();
                }
                oCBCST = null;

                //para seleccionar valor:
                //oCBC.SetSelectedValue(rowIndex, oCBC.ValidValues.Item(0));     

                //////////////////////////////////Cargando CheckBoxes///////////////////////////////////////////
                Grid0.Columns.Item("Guardar").Type = SAPbouiCOM.BoGridColumnType.gct_CheckBox;
                SAPbouiCOM.CheckBoxColumn oCHB = (SAPbouiCOM.CheckBoxColumn)Grid0.Columns.Item("Guardar");

                //////////////////////////////////Habilitando Controles////////////////////////////////////////
                EditText0.Active = false;
                EditText1.Active = false;
                EditText0.Item.Enabled = false;
                EditText1.Item.Enabled = false;
                Button0.Item.Enabled = false;
                Button1.Item.Enabled = true;
                Button3.Item.Enabled = true;                
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show("" + e.Message, "OK");
            }
        }
<br>

0

Could you surround your cargarGrid() call with a try-catch block, and display which line is causing the error?

0

Hi Henning,

Error 1: The request lookup key was not found in any active activation context

Error 2: Object reference not set to an instance of an object

But the error i think is in the sConnectionString, i'm using ui and di api and don't know if am i doing correctly using the SetApplication(), this is the code: (it's weird because, if i use directly the exe file in the debug folder it works but then i register the addon and run from SAP i get the error)

public void SetApplication()
        {
            try
            {
                SboGuiApi = null;
                sConnectionString = null;

                SboGuiApi = new SAPbouiCOM.SboGuiApi();
                //sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
                //sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"; 
                //sConnectionString = Interaction.Command(); 

                //if (Environment.GetCommandLineArgs().GetUpperBound(0) > 0)
                if (System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)) != "")
                {
                    sConnectionString = (String)Environment.GetCommandLineArgs().GetValue(1);
                }
                else
                {
                    sConnectionString = "0030002c0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
                }

                SboGuiApi.Connect(sConnectionString);

                SBO_Application = SboGuiApi.GetApplication(-1);
                SBO_Company = (SAPbobsCOM.Company)SBO_Application.Company.GetDICompany();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show("" + e.Message, "OK");
            }
        }

0