cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to stop add-on

Former Member
0 Kudos

Hi all!

I've this question.

When I click "Stop" in Add-On manager, my add-on ends, but SAP Business One sends the error message "Failed to stop add-on".

My source code is:

Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent

Select Case EventType

Case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged

End

Case SAPbouiCOM.BoAppEventTypes.aet_ShutDown

End

Case SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition

End

End Select

End Sub

Someone can help me?

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

Hi all,

There's recently been a SAP note brought out that provides a solution to this problem. The note number is 891115 and can be found at the following address:

https://websmp103.sap-ag.de/~form/handler?_APP=01100107900000000342&_EVENT=DISPL_TXT&_NNUM=891115&_N...

For those of you without SAP Marketplace access, the solution is to create a global thread and then call the sleep method of the thread to create a slight delay before calling the exit method of the application.

In C#, the code looks something like this (sorry for the lack of indentation but that's the fault of this forum :P):

using System

using System.Threading

namespace myNameSpace

{

public class SubMain

{

private Thread oThread;

private SAPbouiCOM.Application m_sboApp;

public SubMain()

{

ThreadStart oThreadDelegate = new ThreadStart(SubMain.ShutDown);

oThread = new Thread(oThreadDelegate);

SetApplication();

}

public void SetApplication()

{

// Usual connection code goes in here

...

...

this.m_sboApp.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(this.m_sboApp_MenuEvent);

this.m_sboApp.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(this.m_sboApp_ItemEvent);

this.m_sboApp.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(this.m_sboApp_AppEvent);

}

private void m_sboApp_AppEvent(SAPbouiCOM.BoAppEventTypes AppEventType)

{

// Respond to application events and close the addon

switch(AppEventType)

{

case SAPbouiCOM.BoAppEventTypes.aet_ShutDown:

case SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition:

case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged:

{

oThread.Start();

break;

}

}

}

private static void ShutDown()

{

System.Threading.Thread.Sleep(100);

System.Windows.Forms.Application.Exit();

}

}

}

I've tested this only on 2004A so far and only in C# but it works fine for me.

Hope this helps,

Owen

0 Kudos

Thanks for your clear answer. I had access to "SAP Marketplace" and found note number is 891115 which says "You can find the zipped sample as an attachment". I downloaded it through "SAP Download Manager" Version 2.1.130. However I could not unzip it. It was something like a MIME attachment. It could not be opened by Winzip. I only have Business One, could you please refer me to a URL where viewing instructions for non R/3 users are given

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Fakher,

You have the code sample in the message before yours.

You only have to wait for a short time before ending your application on the Shutdown application event.

Hope it helps

Trinidad.

0 Kudos

Thanks you all for your help. It is now very clear how to safely end the Add-on.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi All,

Try to delete your object after disconnecting from the Company with the Garbage Collector.

Former Member
0 Kudos

Will try that Damien. Just wanted to say that I'm only getting problemon 2004, not 2005.

Former Member
0 Kudos

Were you able to resolve this issue? Please let me know.

0 Kudos

> Hi All,

>

> Try to delete your object after disconnecting from

> the Company with the Garbage Collector.

Damien,

I have positively confirmed using the "Windows Task Manager" that Add-on is shutdown.

In B1DE, following was the handler:

public override void OnShutDown(){

B1Connections.diCompany.Disconnect();

B1Connections.diCompany=null;

B1Connections.theAppl=null;

System.GC.Collect();

System.GC.WaitForPendingFinalizers();

System.Windows.Forms.Application.Exit();

return;

}

It appears to be a bug in 2004, as despite successful shutdown of Add-On, it still issues "Failed to stop Add-On" message although Add-On process disappeared from "Windows Task Manager".

Former Member
0 Kudos

I have the same problem.

Any help?

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Have you tried to call disconnect on your DICompany object and stop your addon execution at the Shutdown and ServerTerminition application events?

Regards

Trinidad.

Former Member
0 Kudos

Hi Trinidad,

I have the same problem. I followed your advice and tested again. I still get the same error.

Thanks,

Adele

0 Kudos

Trinidad,

I am using B1DE for 2004. I am getting the same error. I tried the following and still getting the annoying "Failed to stop Add-on". Can you please help

public override void OnShutDown() {

// ADD YOUR TERMINATION CODE HERE ...

B1Connections.theAppl.StatusBar.SetText("Shutting down my add-on", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success) ;

B1Connections.diCompany.Disconnect();

B1Connections.theAppl=null;

System.GC.Collect();

System.GC.WaitForPendingFinalizers();

System.Windows.Forms.Application.Exit();

}

Former Member
0 Kudos

I am beginning to think that this is a bug in 2004. I was getting the same issue in 2004. I then upgraded the code to 2005 and the process worked fine. I did not have to make any change to the code at all.

Gopal

Former Member
0 Kudos

Hi Gopal,

Yes, see my response above. I came to the same conclusion: <i>Just wanted to say that I'm only getting problemon 2004, not 2005</i>

Adele