-1

I have an add-on programmed in c# for SAP B1. I created an installer and successfully registered it under SAP B1.But the problem is whenever I start the add-on in SAP B1, after sometime it says "add-on connection timed out". And in add-on manager window it says add-on failed. Yet I can use all the functionality of the add-on. Only thing I can't do is, disconnect the add-on using the "add-on manager" window. But if I close SAP B1, it also triggers the app closing event.

My question is why does this message appear even though it works completely fine? Does it have anything to do with the installation time which you have to give during the add-on installer creation wizard? Because my add-on takes around 45 seconds to start and I gave only 25 seconds for installation time, thinking there's no connection between installation-time and actual start up time of the add-on.

I would really appreciate if any expert can explain the reason for this and the way to avoid it.

I doubt there's something wrong with my connection method to SAP B1. Yet for the completeness of the question it can be seen below.

public void set_application()
{
        SAPbouiCOM.SboGuiApi SboGuiApi = null;
        string sConnectionString = null;

        SboGuiApi = new SAPbouiCOM.SboGuiApi();

        // by following the steps specified above, the following
        // statment should be suficient for either development or run mode
        //System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)

        if ((System.Environment.GetCommandLineArgs().Length > 1))
        {
            sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";  
        }
        else
        {
            sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"; 

        }

        try
        {
            // If there's no active application the connection will fail
            SboGuiApi.Connect(sConnectionString);
        }
        catch 
        { //  Connection failed
        System.Windows.Forms.MessageBox.Show("No SAP Business One Application was found");
            System.Environment.Exit(0);
        }

        SBO_Application = SboGuiApi.GetApplication(-1);
} 
Isuru
  • 430
  • 5
  • 21

1 Answers1

0

Before posting the answer I will give some valuable information I found out. If you declare your Main() as (Note the difference in the parameter passed in to the main.

static void Main(String[] Args)  
{   
 sConnection = Args[0];  //This will be the 0 index because Args will only contain the arguments passed  
}  

If you declare your Main() as

static void Main()  
{   
sConnection = Environment.GetCommandLineArgs().GetValue(1).ToString();  //This will be the 2nd arguments, the first arguments(0 index) is the executable.  
}

Because my main is declared as static void Main() I had to change the if/else block as follows

if ((System.Environment.GetCommandLineArgs().Length == 0))
{
    sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
}
else
{
    sConnectionString = System.Environment.GetCommandLineArgs().GetValue(1).ToString();
}
Isuru
  • 430
  • 5
  • 21