我的计算机安装了带有 Access 2016 的 64 位 Office 和 32 位 Access 2010 Redistributable。
我的 VB.NET 程序使用 OleDb 类来读取和写入 .accdb 文件中存储的数据。
如果我使用 AnyCPU 选项编译它,它将停止并显示异常,提示“Microsoft.ACE.OLEDB.12.0 提供程序未注册”,除非我设置“首选 32 位”选项。
但是我的整个应用程序将无法从 64 位处理中受益,它将以 32 位运行 (IntPtr.Size = 4
)
这是为什么呢? .NET OleDb 类不应该找到 Access 2016 64 位附带的 64 位提供程序吗?
我会感谢任何帮助我理解这里发生的情况并希望指导我修复它的人。
最佳答案
您可能安装了 Office 2016 的即点即用版本。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 位 Access Runtime 并安装,例如 the 64-bit version of the Access 2013 Runtime相反或
坚持使用 32 位。不支持在同一台计算机上同时安装 32 位和 64 位版本的 Microsoft.ACE.OLEDB.12.0 驱动程序。 (是的,这很愚蠢)。或者,
您可能想要切换到另一个数据库(例如 SQL Sever Express 或 SQLite)。将 Office 产品与 64 位结合起来往往会引起很多麻烦。
关于vb.net - 在 64 位模式下运行时,提供程序 Microsoft.ACE.OLEDB.12.0 未注册,但 Access 64 位存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40911275/