cancel
Showing results for 
Search instead for 
Did you mean: 

DI API Connection not working in 9.2

former_member231954
Participant
0 Kudos

We just upgraded our SBO to version 9.2 from 9.0 and the code that connects to the company (di api) is no longer working. I still use the SAP9.0 UI+DI API dlls in C# (is there a newer version?).

The code that would connect:

public class SAPDIDao

{

    protected SAPbouiCOM.Application SBOApp = null;

    protected Company oCompany = null;

    public SAPDIDao(SAPbouiCOM.Application SBOApp)

    {

        this.SBOApp = SBOApp;

        SetConnectionContext();

        int errorCode = oCompany.Connect();

        if (errorCode != 0) <-- GOT AN ERROR

        {

            string lastException = "";

            oCompany.GetLastError(out errorCode, out lastException);

            Console.WriteLine("Company connect error: "+errorCode+", msg: "+lastException); <--- ERROR Printed here

        }

    }

    private int SetConnectionContext()

    {

        int setConnectionContextReturn = 0;

        string sCookie = null;

        string sConnectionContext = null;

        oCompany = new Company();

        sCookie = oCompany.GetContextCookie();

        sConnectionContext = SBOApp.Company.GetConnectionContext(sCookie);

        if (oCompany.Connected == true)

        {

            oCompany.Disconnect();

        }

        setConnectionContextReturn = oCompany.SetSboLoginContext(sConnectionContext);

        return setConnectionContextReturn;

    }

}

It worked before, but now I get an error:

Company connect error: -131

(My message is in Hungarian, so I translated it): Connection to the License service did not succeed. The License service's address is invalid or the License service stopped running or not responding.

I can log into SBO an everything looks fine, so I don't think the License server is stopped.

Edit: I also cleared the temp, deleted the %temp%\SM_SBO_DLL dir, rebuilded the project (after clean), restarted both applications, running them both with Administrator rights.

Accepted Solutions (1)

Accepted Solutions (1)

former_member233854
Active Contributor
0 Kudos

Hi Szabolcs,


1. Check if this file exists : C:\*\SAP\SAP Business One DI API\Conf\b1-local-machine.xml

If it exists, then rename file "C:\*\SAP\SAP Business One DI API\Conf\b1-local-machine.xml" to “b1-local-machine.xml.original”

2. Copy the file from here

"C:\*\SAP\SAP Business One\Conf\b1-local-machine.xml"

to

"C:\*\SAP\SAP Business One DI API\Conf\b1-local-machine.xml"

For more info, double check the SAP note https://launchpad.support.sap.com/#/notes/0001658707

Answers (1)

Answers (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Szabolcs,

There is a new version yes, but it's not mandatory to switch. Your code should still connect, especially since it connected in the past.

Since you made the upgrade did you restart the machine?


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

former_member231954
Participant
0 Kudos

I did yes. I completely uninstalled the SBO Client from the computer and installed version 9.2 from the network drive the server provides (b1_shr).

pedro_magueija
Active Contributor
0 Kudos

Hi Szabolcs,

Have a look here: https://scn.sap.com/thread/1209255

If all else fails, try re-installing the ServerTools.


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

former_member231954
Participant
0 Kudos

I don't have a ServerTools folder, but the license manager is running on the server. Other Addons (that are already installed on the server) are just running fine, so I guess something in my code should be wrong. Where can I get the new SDK? The 9.2 installer had an x86 SDK installer, I uninstalled what I had and installed that, yet I only have 9.0 assemblies in my visual studio.

pedro_magueija
Active Contributor
0 Kudos

Hi Szabolcs,

Note that the title of the old interops, are 9.0 but their file version is 9.2.

You should have the new references, but they are located in the Assemblies section in visual studio.



Before you go ahead, have a look here: License server name asked every time on login | SCN (last post)


Since you re-installed B1 perhaps the settings are inconsistent (one with IP and one with machine name)?



Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

former_member231954
Participant
0 Kudos

I am not the one who did the server upgrade, but we used the server ip before, but now we can only list the databases if the server name is selected.

I tried it with the 9.2 assemblies, but same error.

What I don't really understand is, how does logging in with server name or IP affects my addon? My addon will only work if the user logs in with ip? The code looks self explanatory, It should not handle cases like this (i think).

edy_simon
Active Contributor
0 Kudos

Hi Szabolcs.


It happened that I just encountered the same error, It was working in the morning and suddenly this error.

I tried a lot of things and the one worked for me was :

restart VISUAL STUDIO.

not sure if it should work for you though as many factors could cause this error.

And by the way, since SBO 9.1, there is this file :

C:\Program Files (x86)\SAP\SAP Business One SDK\Lib\SAPBusinessOneSDK.dll

You should reference this instead of SAPBobsCOM and SAPBouiCOM

The new dll is a proxy to the two APIs.

Plus point is :

1. No need to re-reference SBO APIs when upgrading the SBO

2. Works for both 32 and 64 bit

Regards

Edy

former_member231954
Participant
0 Kudos

I restared my pc, cleared temp with CCleaner, tried the new dll, still the same error. I am currently reinstalling the SAP Client.

What really is changed from before is we use the server name instead of the server ip, but my code does not touch that.

pedro_magueija
Active Contributor
0 Kudos

Hi Szabolcs,

It's not about your code, but about how B1 finds the license server. Having different settings might cause issues.

Much like everything in SAP B1, it's just a hint, it may not be the cause for your issue.


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

former_member231954
Participant
0 Kudos

I reinstalled SAP (I deleted the "Program Files(x86)/SAP/SAP Business One" folder as well as the AppData/Local/SAP and temp directories, cleared registry, restarted the pc and installed). Yet, I still get the same error. Is there a new connection string for 9.2 ? Or ...

pedro_magueija
Active Contributor
0 Kudos

Hi Szabolcs,

The connection string is passed via the command line when an add-on is in "production".

If you are using the development connection string (provided with the documentation), you could have issues with the add-on connecting.

One more thing can you ping the license server (servername:30000)?


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.

former_member231954
Participant
0 Kudos
Before you go ahead, have a look here: License server name asked every time on login | SCN (last post)

I just realized that your link was the solution, thanks!

pedro_magueija
Active Contributor
0 Kudos

Hi Szabolcs,

No worries, glad it worked out in the end.

Cheers.


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer was helpful or correct consider marking it as such.