提供商 Microsoft.ACE.OLEDB.12.0 在 运行 处于 64 位模式时未注册,但 Access 64 位存在

Provider Microsoft.ACE.OLEDB.12.0 not registered while running in 64bit mode but Access 64bit is there

我的电脑同时安装了 64 位 Office with Access 2016 和 32 位 Access 2010 Redistributable。

我的 VB.NET 程序使用 OleDb 类 读取和写入存储在 .accdb 文件中的数据。

如果我使用 AnyCPU 选项编译它,它将停止并显示一个异常 "Microsoft.ACE.OLEDB.12.0 provider is not registered",除非我设置 "prefer 32 bit" 选项。

但是我的整个应用程序不会受益于 64 位处理,它将 运行 作为 32 位 (IntPtr.Size = 4)

这是为什么? .NET OleDb 类 不应该找到 Access 2016 64 位附带的 64 位提供程序吗?

我会感谢任何帮助我理解这里发生的事情并希望指导我修复它的人。

您可能安装了 Office 2016 的 Click-To-运行 版本。According to Microsoft:

Click-to-Run installations of Office run in an isolated virtual environment on the local operating system. [...] You must install an MSI installation of the Microsoft Access Database Engine from one of the following sources so that the calling application can locate the [Microsoft.ACE.OLEDB.12.0 OLEDB provider].

因此,您有以下选择:

  • 摆脱 32 位访问 运行 时间并安装,例如 the 64-bit version of the Access 2013 Runtime

  • 坚持使用 32 位。不支持在同一台机器上的 32 位和 64 位版本中安装 Microsoft.ACE.OLEDB.12.0 驱动程序。 (是的,这很愚蠢)。或者,

  • 您可能想切换到另一个数据库(例如 SQL Sever Express 或 SQLite)。结合使用 Office 产品和 64 位往往会引起很多麻烦。