SAP B1 v10:DI-API - 类型初始值设定项引发异常

问题描述

我正在尝试在 Visual Studio for SAP B1 版本 10.00.150 中以调试模式 (x64) 运行插件。这个插件在 9.3 版本中运行良好。

我已经用代码中的正确版本更新了 SAP bob 和 boui 的 .dll 文件。这是一个 Hana DB。我已经确定我已经输入了正确的连接字符串进行调试。

我以管理员身份同时运行 SAP B1 客户端 x64 和 Visual Studio

但是,我在这一行遇到错误

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

错误

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

这是正在运行的 SAP 版本:

enter image description here

我在代码中为该版本添加了正确的 .dll 文件

enter image description here

我该如何解决这个错误

解决方法

该错误意味着 .net 运行时无法找到和实例化 DI-API COM 对象。该问题可能是由以下原因之一造成的:

  • 未安装 DI-API
  • 安装的 DI-API 的位数与您的插件的位数不匹配
  • 您安装了 9.x DI-API(不同的 COM GUID)

正确的 DI-API 通常与 v10 客户端一起安装,但我认为这不是先决条件。如果您安装了 DI-API,它通常会显示在 Windows 添加/删除软件列表中。确保已安装,如果已安装,请尝试重新安装。