Showing results for 
Search instead for 
Did you mean: 

MS Installer for .NET and SBO Add-ON - Example wanted

Former Member
0 Kudos

Hi all,

I need some help from you .NET - SBO wizards out there.

I wonder if anyone has an example or maybe some ideas of where to direct me for getting info on how to get the deployment of a VB.NET-based Add-On to work.

I'm using Visual Studio .NET 2003 and with that comes the Windows Installer 2.0 which differs from the examples provided in chapter 4 - "Installing and Registering an Add-on" of the pdf "SDK API - Standards and Guidelines". Well, so I think at least but maybe someone knows better.

The ideal would of course be if someone had a skeleton .NET project that he/she would share, which has the Business One-specific deployment instructions already in place.



Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

we sample of register an add-n in VB. I do not know about to this sample.

You right that it is not in VB.Net. I will check if we can migrate this sample to  .Net.

This VB project is just for registring the add-on no mater in which langugae is written.

We have a lot of sample in the 6.5 installation of different project in VB.Net.


Former Member
0 Kudos

Hi there,

I do not know whether this is what you need, but I'll give it a shot.

I found that the main problem in .Net is that the long value in VB6 is not equal to the long value in VB .Net.

If an integer value is used whereever SAP samples use a long value, all functions will work correctly. Here is how to register the SAP functions in VB .Net.

HTH, Lutz Morrien

Public Class AddonInstaller

  Private Declare Function SAPUnRegisterAddOn Lib "SBOAddonReg.dll" _

             Alias "UnRegisterAddOn" (ByVal installDataFile As String) As Boolean

  Private Declare Function SAPRegisterAddOn Lib "SBOAddonReg.dll" _

             Alias "RegisterAddOn" () As Boolean

  Private Declare Function SAPGetInstallPath Lib "SBOAddonReg.dll"

                                      Alias "GetInstallPath" (ByVal installDataFile$, _

                                                                       ByVal outStr$,

                                                                       ByVal lLen As Integer) As Integer

End Class

Former Member
0 Kudos

Hi Lutz,

I put the declare statements in my setup application and tried

this lines:

        Dim l_strFile As String

        Dim l_strInstPath As String

        Dim l_len As Integer

        Dim l_ret As Integer

        l_strFile = ".......SBOAddOnRegData.sld"

        l_ret = SAPGetInstallPath(l_strFile, l_strInstPath, 1000)

        Console.WriteLine("path: " & l_strInstPath & " return: " & l_ret)

I Always get an empty l_strInstPath variable and l_ret = 0

Whats wrong?

Former Member
0 Kudos

I found the problem.

I only have to initialize the string with the length of the

return value.

l_strInsPath = Space(68)

Former Member
0 Kudos

Sorry for the delay Ingo,

here is the official SAP sample code for registration in VB6.

HTH Lutz Morrien

Option Explicit

'long GetInstallPath(const char *installDataFile,char *outStr,long len);

Private Declare Function GetInstallPath Lib "SBOAddonReg.dll" _

    (ByVal installDataFile$, ByVal outStr$, lLen As Long) As Long

'BOOL RegisterAddOn(void);

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

'BOOL UnRegisterAddOn(const TCHAR *installDataFile);

Private Declare Function UnRegisterAddOn Lib "SBOAddonReg.dll" (ByVal installDataFile As String) As Boolean

Private g_sInstallPath      As String

Private g_sInstallFullPath  As String

Private g_sPreviousDir      As String

Private g_sAddOnExeName     As String

Private Sub CmdAddOnStr_Click()

    Shell App.Path & "AddOnRegDataGen.exe", vbNormalFocus

    CmdReg.Enabled = True

End Sub

Private Sub CmdExit_Click()


End Sub

Private Sub CmdReg_Click()

    Dim sPath As String

    Dim lLen As Long

    Dim InstallStrFile As String

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

    'Coping the addon exe into the path location I got

    MsgBox "Please copy your Addon exe file into: " + Trim$(sPath)

    'Writing to the registry

    If RegisterAddOn = 1 Then

        MsgBox "AddOn Was Registered Successfully"

        CmdUnReg.Enabled = True


        MsgBox "Failed To Register AddOn"

    End If

End Sub

Private Sub CmdUnReg_Click()

    Dim InstallStrFile As String

    InstallStrFile = App.Path & "SBOAddOnRegData.sld"

    If UnRegisterAddOn(InstallStrFile) = 1 Then

        MsgBox "AddOn Was UnRegistered Successfully"


        MsgBox "Failed To UnRegister AddOn"

    End If

End Sub

Former Member
0 Kudos

I think you need to pass a string with a fixed size for the resulting path, and you need to pass the size of that string in the last variable.  When this is returned, you must extract the string from the buffer.

Here is the front-end funtion that I wrote for this:

Public Function GetInstallPath(sRegFile As String) As String

'// Use this version of function to get the path name returned

'//   as a variable length string

Dim sLong As String * 128

Dim iLen As Long, iRet As Long

iLen = Len(sLong)

iRet = GetInstallPathA(sRegFile, sLong, iLen)

GetInstallPath = StringFromBuffer(sLong)

End Function

StringFromBuffer() is defined in Common.bas in VB6's setup1 project.  It basically finds the first null character (vbNullChar) and returns all the characters before that as a string.