cancel
Showing results for 
Search instead for 
Did you mean: 

Registering Add-on in 2004

Former Member
0 Kudos

Hi Everyone,

I have an add-on which I have created for SAP Business One 2004 using C#.NET and Visual Studio 2003. I have finally managed to get the add-on to install and run on my 2004 instance based on the code in the sdk samples, however somethings aren't quite working right:

1) The VS2003 compiler produces 2 files Interop.SAPbobsCOM.dll and Interop.SAPbouiCOM.dll, my application requires these to be placed in the same directory to run - is this normal? (currently I have written my installer to extract these during installation to make it work)

2) If I go to my task manager when the add-on has started, even though the application isn't very large (and mimics a few of the sdk examples) it creates a memory footprint of 60,000K which is bigger than most applications, including SBO - is this what most people find or am I doing something wrong?

3) In add-on Manager if I stop the add-on, my application continues to run in the background. Is there an event that I am supposed to catch to detect my add-on has been stopped, I thought of creating a Timer in my application to test the connection periodically, I would be keen to hear any advice on this.

Any help would be much appreciated on any of these! If anyone would like my C# examples I would be happy to provide some of these, or if you would like some help with installing an add-on I have conquered a few troubles along the way.

Thanks,

Daniel

daniel.archer@businessbasics.co.nz

Accepted Solutions (1)

Accepted Solutions (1)

former_member185703
Active Contributor
0 Kudos

Hi Daniel,

Re 1)

Yes, this is normal. The two files you mentioned are .NET wrappers for the COM interfaces (just like SDK's Java Connector for the DI API is for Java development) so that you can without any additional efforts use COM in your C# project.

Re 2)

If the memory footprint comes from data you load - or structures you build, you should try to find a way to do this after connecting to UI API. This should always happen first.

I.e. you should think about how to make sure that everything (meta data etc.) is in place and your Add-On is ready to run - or decide not to start and do initialization work afterwards. You could still terminate your Add-On - even though you already connected to UI API, if you have to.

Re 3)

Unfortunately there is no event for that (at least not yet).

I think you should (until then) handle the click or item pressed event on item "11" ("Stop" button) on form (type!) 60059 + check the current selection in the matrix (item "3") whether or not it affects your Add-On.

HTH,

Frank

former_member185703
Active Contributor
0 Kudos

Hi,

Re 3)

I am pleased that I can tell you that there is an event now (build 185.05!) - I just made a mistake so I didn't notice that when I checked it again:

SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition

is the AppEvent that tells you that your AddOn that it the user has hit "Stop".

Apparently, Add-On Manager does not really like that yet... (status is "Failed")

Sorry for the wrong information,

Frank

Former Member
0 Kudos

This thread helped a lot to make my add-on installation be performed correctly. Thank you, guys.

Frank,

> Apparently, Add-On Manager does not really like that

> yet... (status is "Failed")

This might be what I found with my add-on too. In most cases (9 times out of 10) when I stop my add-on from the Add-On Manager SBO form, the add-on manager reports a failure of stopping the add-on, while the add-on actually exits correctly. However, in some cases the add-on manager reports successful stopping.

What could be the problem? Is there any workaround?

Thank you again,

Miki

Former Member
0 Kudos

Hi,

this happens all the time.

When I try to stop my Add-On I get the message "Failed to stop Add-On".

I'm catching the "aet_ShutDown" and "aet_ServerTerminition" events and execute the next code:

DF_Menus_Remove SBO_Application 'Routine to remove menus.

SBO_Company.Disconnect

End

The Add-On exits but stays in state "Failed".

It's something wrong in my code?

Former Member
0 Kudos

I've created an issue on SAP Support and this problem appears to be a "cosmetic issue".

Does any one experienced this problem?

Former Member
0 Kudos

Hi Fernando,

Yes I have experienced the same problem with my add-ons, the add-on says failed when stopped even though it seems to have stopped successfully.

I guess if it works its okay, but it isn't nice to have the failed message come up....

Daniel

Former Member
0 Kudos

The SAP solution:

This behavior is caused by the use of the END method.

The END method terminates the connection between the Addon and the

UI server before the addon administrator released the Add-on.

This is the reason we get the "Failed to stop AddOn" message.

The Add-On administration tries to "connect" to the Add-On after the END

method and fails since the Add-On is no longer running.

Therefore we can't use the END method here.

While clicking on the "Stop" button, The Add-On administration calls

"aet_ServerTerminition" application event.

The Add-on termination should be done by the Add-On AFTER this event.

While using VB6 in order to terminate the Add-On, we can use the

"Unload form" method (instead of END).

Former Member
0 Kudos

Hi,

I use the following code to terminate (and begin) my Add-Ons in Vb.net:

Module SubMain

'Normal Begin Function

Public Sub Main()

Dim oMyAddOn As MyAddOn

oMyAddOn = New MyAddOn

System.Windows.Forms.Application.Run()

End Sub

'This Sub is used after B1 calls aet_ServerTerminition or aet_ShutDown

Public Sub CloseApp()

'My AddOn Class has a Thread object called TmpThread

MyAddOn.TmpThread.Sleep(10)

System.Windows.Forms.Application.Exit()

End Sub

End Module

'This is the Thread in My class

Public Shared TmpThread As New Threading.Thread(AddressOf CloseApp)

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

If EventType = SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition Or _

EventType = SAPbouiCOM.BoAppEventTypes.aet_ShutDown Then

TmpThread.Start()

Maybe this is not the best way but works fine, if someone find a better way, please publish it.

Ribeiro Santos

Former Member
0 Kudos

Ribeiro:

That seems to work just fine. Thanks for posting.

Ty Babcox

Former Member
0 Kudos

> While clicking on the "Stop" button, The Add-On

> administration calls

> "aet_ServerTerminition" application event.

> The Add-on termination should be done by the Add-On

> AFTER this event.

> While using VB6 in order to terminate the Add-On, we

> can use the

> "Unload form" method (instead of END).

Hi Everyone

3) Have anybody found a Solution to stop the AddOn in the addOn Manager Correctly with VB6 ? I has also catch the Event :

Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes)

Select Case EventType

Case aet_ShutDown:

End

Case aet_ServerTerminition:

End

End Select

End Sub

How can i use the Unload Form method to stop my AddOn?

Thanks

Yassine

Answers (5)

Answers (5)

Former Member
0 Kudos

hi!Barend

thank you for you help!

i write code with VB6.

i remove the connection string from your command line arguments.

show the message :command line ....

<b>code:</b>

Private Declare Function GetInstallPath Lib "SBOAddonReg.dll" (ByVal installDataFile As String, ByVal outStr As String, ByRef lLen As Integer) As Integer

Private Declare Function RegisterAddOn Lib "SBOAddonReg.dll" () As Boolean

Private Sub Class_Initialize()

sPath = Space(1024)

'Getting the sPath where I have to install the addon exe

InstallStrFile = App.Path & "\SBOAddOnRegData.sld"

lLen = GetInstallPath(InstallStrFile, sPath, Len(sPath))

SetApplication

For j = 1 To 10

sDocEntry(j) = ""

selectedRowIndex(j) = 0

Next

j = 1

eventCount = 0

flag = 0

ReturnValue = 0

DelFlag = 0

If Not SetConnectionContext = 0 Then

SBO_Application.MessageBox "Failed setting a connection to DI API"

End

End If

If Not ConnectToCompany = 0 Then

SBO_Application.MessageBox "Failed connecting to the company's Data Base"

End

End If

If RegisterAddOn = 1 Then

MsgBox ("AddOn Was Registered Successfully")

Else

MsgBox ("Failed To Register AddOn")

End If

AddFormToMenu

'Coping the addon exe into the path location I got

'MsgBox ("Please copy your Addon exe file into: " & Trim(sPath))

End Sub

Private Sub SetApplication()

Dim SboGuiApi As SAPbouiCOM.SboGuiApi

Dim sConnectionString As String

Set SboGuiApi = New SAPbouiCOM.SboGuiApi

sConnectionString = <b>Command</b>

SboGuiApi.Connect sConnectionString

Set SBO_Application = SboGuiApi.GetApplication()

End Sub

Former Member
0 Kudos

I have a trouble about registering add-on .

I register add-on in 2004 .

(1)i generate file use AddOnRegDateGenerate.exe.

(2)connection string use for COMMAND

have error message tell me command line parameter invalidation when B1 start up .

who can help me?

i write code with VB6.

barend_morkel2
Active Contributor
0 Kudos

Yawei,

Use this for your connection:


oSboGuiApi = New SAPbouiCOM.SboGuiApi

If Environment.GetCommandLineArgs.Length > 1 Then
' Runtime mode
sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
Else
' Development mode
sConnectionString = "5645523035496D706C656D656E746174696F6E3A4E31343537343130363536F2136B6DF53B110A113483A18D02F09A9A4A911C"
End If

oSboGuiApi.Connect(sConnectionString)

oApp = oSboGuiApi.GetApplication()

''''''''''''''''''''

What you must do is remove the connection string from your command line arguments (in the project properties) then the code

<b>

sConnectionString = Environment.GetCommandLineArgs.GetValue(1)

</b>

will get the string that the UI (SBO client on your local machine) will pass to you - It should work....

Former Member
0 Kudos

I have a trouble about registering add-on .

I register add-on in 2004 .

(1)i generate file use AddOnRegDateGenerate.exe.

(2)connection string use for COMMAND

have error message tell me command line parameter invalidation when B1 start up .

who can help me?

rasmuswulff_jensen
Active Contributor
0 Kudos

Hi... I also use C# and here are my notes to your 3 questions.

1) I also get the Interop-dll's and I also need to copy these files in order for my addon to work

2) My addon also takes about 60-65MB of RAM... It seems strange why it takes so much (Can anyone inhere from SAP explain)?

3) I have the same problem with stopping the addon (Say the addon faild to stop even though it did)... Right now I have some problems with my addon disconnect after startup (Event though I have a thread keeping the addon alive)... The problem only occur when registation (exe + ard)... Not during develop...

Former Member
0 Kudos

Hi Rasmus,

I have also found that when I load SAP Business One 2004 A for the first time and it auto-loads the add-on, the first time it tries to load it the add-on fails because it takes too long to load up (there seems to be a 15 second limit for add-ons to load up?). I think this is caused by the fact that the add-on is so large in memory (60-65MB). If I click restart add-on, it loads up successfully because it is already cached in memory from the first time.

Does anyone know if there is a way to let SBO know to wait for the add-on to load?

Thanks,

Daniel

Former Member
0 Kudos

In terms of the question 3) in the above, I have since managed to get SBO environment to close the add-on successfully - however SBO now complains that it failed, wheras before it said successful even though the addon was still running in the background.

The changes I made to get it to close were:

1) I made the add-on a singleton class to prevent it from being started multiple times (this probably wouldn't have made any difference, but at least prevented multiple instances running)

2) In in my startup class I continue to run the application unless it is connected...

(Phantom Explosion is my add-on name)

{

[STAThread]

static void Main()

{

PhantomExplosion objPhantomExplosion = PhantomExplosion.Instance();

if(objPhantomExplosion.objCompany.Connected)

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

else

System.Windows.Forms.MessageBox.Show("Addon Stopped");

}

}