0

I am trying to run an addon in debug mode (x64) in Visual Studio for SAP B1 version 10.00.150. This addon worked well in version 9.3.

I have updated the .dll files for SAP bobs and boui with the correct version in the code. This is a Hana DB. I have made sure I have put in the correct connection string for debug.

I am running both SAP B1 client x64 and Visual Studio as administrator.

However, I get an error at this line:

// First initialize the Company object
Company = new SAPbobsCOM.Company();

Error:

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'SAP_DMS_Integration.Helpers.SboConnection' threw an exception.
Source=SAP_DMS_Integration
StackTrace:
at SAP_DMS_Integration.Helpers.SboConnection.get_SboApplication() in C:\Users\sconsult1\Desktop\CCL\DMS\SAP_DMS_Integration\SAP_DMS_Integration\Helpers\SboConnection.cs:line 17
at SAP_DMS_Integration.GUI..ctor() in C:\Users\sconsult1\Desktop\CCL\DMS\SAP_DMS_Integration\SAP_DMS_Integration\GUI.cs:line 33
at SAP_DMS_Integration.Program.Main() in C:\Users\sconsult1\Desktop\CCL\DMS\SAP_DMS_Integration\SAP_DMS_Integration\Program.cs:line 17

Inner Exception 1:
FileNotFoundException: Retrieving the COM class factory for component with CLSID {632F4591-AA62-4219-8FB6-22BCF5F60100} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007E).

This is the SAP version running:

enter image description here

I have added the correct .dll files for the version in code:

enter image description here

How do I fix this error?

Kinyanjui Kamau
  • 1,890
  • 10
  • 55
  • 95

3 Answers3

1

The error means the .net runtime can't find and instantiate the DI-API COM object. The issue is probably due to one of these:

  • DI-API is not installed
  • The bitness of the installed DI-API doesn't match the bitness of your Addon
  • You have a 9.x DI-API installed (different COM GUID)

The correct DI-API is often installed along with the v10 client, but I don't think it's a prerequisite. If you have DI-API installed it will usually show up on the Windows Add/Remove Software list. Make sure it's installed, and if it is try reinstalling it.

Daz
  • 2,833
  • 2
  • 23
  • 30
  • see edited question. DI-API is installed and I have included the correct versions, not the 9.3 ones. – Kinyanjui Kamau Jul 15 '21 at 08:24
  • I'd uninstall and reinstall DI separately from the client. If it says it can't find it, it probably can't find it. The only other option would be to reference SAPBusinessOneSDK.dll (instead of both DI and UI COM objects) and hope that has better luck instantiating the COM object. – Daz Jul 15 '21 at 08:48
  • what do you mean uninstall & reinstall separately from client? – Kinyanjui Kamau Jul 15 '21 at 09:01
  • Use the separate DI-API installer from the B1 setup bundle to remove it and add it back again (without affecting the B1 client). "Packages.x64\DI API\setup.exe" – Daz Jul 15 '21 at 09:14
  • Same issue after removing and adding...I will keep trying to solve – Kinyanjui Kamau Jul 15 '21 at 09:36
0

I would recommend you to always install both the 32 bit & 64 bit version of DI API on where you are going to run your project, and reference the SAP Business One SDK DLL in your project (less hassle as it will choose the correct DI API version (bit wise) depending on the environment.

Daz mentioned bitness, which is what I am talking about here, just spelling it out a bit more :P 100% of the times I'm struggling with the Retrieving the COM class factory for component it's based on me having the wrong DI API installed. Sometimes I was sure I wouldn't need the 32 bit but my projects could contain another DLL that forced the project to build as 32 bit, hence DI API 64 bit wouldn't be sufficient.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Egil Hansen
  • 158
  • 2
  • 8
0

you have most likely set your project's bitness to Any-CPU, but your projects target was still set to Prefer32bit=true (as it was SAP9.3 projects) this way the VisualStudio was trying (and failing) to find the 32bits version of DI API.

Once i have changed Project's PlatformTarget to x64 the Prefer32bits went to false and became greyed out.

(i just had this issue today and this was the solution)