我花了过去三个小时尝试解决此问题但无济于事,因此我来这里寻求帮助。我之前已经搭建了该数据库的一个子集,但在此之前是在从 32 位 Office 2010 升级到 64 位 Office 365 之前。完整详细信息如下:
Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
经过大量研究,我将最初的问题范围缩小到系统无法找到 MS Access DAO dll。修复 O365 软件包无法解决该问题。经过绝望的措施,我调查了注册表中的 ID,发现它指向 Access 2010 32 位运行时的旧 dll 位置。
更新注册表以指向 O365 附带的新 dao dll 允许一些小的进展:
Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 800700c1 is not a valid Win32 application. (0x800700C1)
所以在这个阶段,我知道我已经能够成功指向一个dll,但是由于VS2019是32位应用程序,因此由于我的O365提供了64位dll而失败。尝试将我的应用程序编译为 64 位完全失败,因为脚手架告诉我它无法与 64 位应用程序一起使用(因为它通过 VS2019 运行,这是 32 位)。
Could not load file or assembly '[MyAssembly], Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.
如果您有 Office365 即点即用,Microsoft 会阻止安装任何其他运行时,因此我无法安装之前可用的 32 位运行时。所以我只是解压运行时安装程序,并直接指向dll。这取得了更多进展,但导致 dll 无法初始化。
Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 8007045a A dynamic link library (DLL) initialization routine failed. (0x8007045A).
此时,除了在尚未升级到 O365 的计算机上进行脚手架之外,我不知道还能做什么才能重新获得搭建脚手架的能力。
编辑:继续尝试,每次尝试 64 位时都会出现此错误。
Microsoft.EntityFrameworkCore.Design.OperationException: Could not load assembly '[MyProject]'. Ensure it is referenced by the startup project '[MyProject]'. ---> System.BadImageFormatException: Could not load file or assembly '[MyProject], Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.
脚手架不兼容 64 位。
以下错误消息表明您的 Windows 注册表项已混乱:
Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 8007045a A dynamic link library (DLL) initialization routine failed. (0x8007045A).
要恢复丢失的 Windows 注册表项,您需要修复/重新安装 MS Office。在处理 MS Office 应用程序时,这是一个广泛存在的问题。