无法在 Interop 中从注册表中读取密钥(HRESULT 异常:0x80040150 (REGDB_E_READREGDB))。QBFC13.IQBSessionManager

Could not read key from registry (Exception from HRESULT: 0x80040150 (REGDB_E_READREGDB)) at Interop.QBFC13.IQBSessionManager

在部署 QuickBooks Web 连接器调用的 Web 服务更新期间,我们没有遇到与 Interop.QBFC13.IQBSessionManager 相关的一堆问题。请注意我们的代码都在开发环境中工作,并且过去在我们的生产服务器上工作过。

我们 运行 在 64 位 Windows 2016 服务器上,但是 运行 我们 Web 服务的 IIS 站点是 32 位的,并且确实将项目编译为 x86 并验证了dll 是 x86.

我们从这个错误开始,然后将 App Pool Identity 权限添加到与此 class Id/

关联的注册表项

Error message: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidCastException: Unable to cast COM object of type 'Interop.QBFC13.QBSessionManagerClass' to interface type 'Interop.QBFC13.IQBSessionManager'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{50F59D7F-4E65-45D8-8F19-135F9FE05296}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

之后,错误信息由No such interface supported...变为Library Not Registered

现在它给

System.Runtime.InteropServices.COMException: Could not read key from registry (Exception from HRESULT: 0x80040150 (REGDB_E_READREGDB)) at Interop.QBFC13.IQBSessionManager.CreateMsgSetRequest

但它没有说明它正在尝试读取哪个注册表项。

它总是在我们的代码中触发错误的相同位置:

IMsgSetRequest msgSetRq = sessMgr.CreateMsgSetRequest(qbXMLCountry, (Int16)qbXMLMajorVers, (Int16)qbXMLMinorVers);

我们已尝试卸载、重新安装 QB SDK、QBFC13_0Installer.exe 和 QBXMLRP2Installer.exe...所有这些都在卸载和重新安装后重新启动。

不是实际问题的真正答案,但您通常可以使用 Process Monitor.

找出注册表的权限(和其他)问题

实际问题似乎是 IIS APPPool 没有正确的注册表项权限。