avatar image
Former Member

C#. SDK. How can I get second application instance?

When I try to obtain a second instance of the application error occurs: "An attempt was made to referance a token that does not exist". Code below returns 32-chars token. Token can be used once? Thanks.

SboGuiApi guiApi = new SboGuiApi();			
string[] startArgs = Environment.GetCommandLineArgs();		
if( startArgs.Length > 1 )
{					
    guiApi.Connect( startArgs[1].ToString() );
}
else
{
    guiApi.Connect( DEV_CONNECT );
}
				
AppReference = guiApi.GetApplication( -1 );

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 24, 2017 at 11:17 AM

    Hi Roman,

    If I understood your case, I did this test and no problem occurred. In this test I get two instance of Application object but those connect on the same client of SAP Business One.

                    SAPbouiCOM.SboGuiApi objSBOGuiApi = null;
                    objSBOGuiApi = new SAPbouiCOM.SboGuiApi();
                    objSBOGuiApi.Connect((string)Environment.GetCommandLineArgs().GetValue(1));
                    oApplication = objSBOGuiApi.GetApplication(-1);
    
                    oApplication.MessageBox("Test one");
    
                    objSBOGuiApi = null;
                    objSBOGuiApi = new SAPbouiCOM.SboGuiApi();
                    objSBOGuiApi.Connect((string)Environment.GetCommandLineArgs().GetValue(1));
                    oApplication2 = objSBOGuiApi.GetApplication(-1);
    
                    oApplication2.MessageBox("Test two");
    

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content