/scripts/ahub.form.attachments.js
0

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

Jan 24, 2017 at 10:07 AM

120

avatar image
Former Member

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 );

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

1 Answer

DIEGO LOTHER Jan 24, 2017 at 11:17 AM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Skip to Content