Microsoft.Jet.OLEDB.4.0'提供商未在本地计算机上注册

发布于 2024-08-16 12:29:48 字数 352 浏览 3 评论 0原文

我在 32 位 Windows 2008 服务器上创建了一个用 .NET 3.5 开发的 Windows 应用程序。在 64 位服务器中部署应用程序时,它显示错误“Microsoft.Jet.OLEDB.4.0'提供程序未在本地计算机上注册”。

因此,作为这个问题的解决方案,我将项目的构建属性更改为X86,以便它将以32位模式构建,并在32位机器中重建项目。但是,同一个项目使用其他数据库驱动程序(DB2、SQL 等)来连接到其他数据库。因此,当我在 64 位操作系统中再次部署应用程序时,它会抛出异常“尝试在 32 位平台上加载 64 位程序集。”

我正在使用 Microsoft.Jet.OLEDB.4.0 驱动程序进行读写到 Excel (.xls)

I created a windows application developed in .NET 3.5 in a 32 bit Windows 2008 server. When deployed the application in a 64 bit server it shows the error "Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine ".

So as a solution to this issue, i have changed the build property of the project to X86, so that it will build in 32 bit mode, and rebuild the project in the 32bit machine. But, the same project uses other DB drivers (DB2, SQL etc.) to connect to other databases. So when i deployed my app again in the 64 bit OS, it throws the exception " Attempted to load a 64-bit assembly on a 32-bit platform. "

I am using the Microsoft.Jet.OLEDB.4.0 driver to read and write to the Excel (.xls)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(22

傲世九天 2024-08-23 12:29:48

我找到了解决这个问题的方法。我在问题中描述的问题基本上是由于 64 位操作系统中的 Microsoft.Jet.OLEDB.4.0 驱动程序 不兼容所致。

因此,如果我们在 64 位服务器中使用 Microsoft.Jet.OLEDB.4.0 驱动程序,我们必须强制我们的应用程序以 32 位模式构建(这是我在对此进行广泛搜索时找到的答案已知问题),这会导致我的代码的其他部分被破坏。

幸运的是,现在微软已经发布了64位兼容的2010 Office System驱动程序,它可以用来替代传统的Microsoft.Jet.OLEDB.4.0驱动程序。它可以在 32 位和 64 位服务器上运行。我已将它用于 Excel 文件操作,并且在这两种环境中都运行良好。 但此驱动程序处于BETA 版本。

由于 2010 版链接不再可用,您目前可以从 Microsoft Access 数据库引擎 2016 可再发行组件

I found a solution for this problem. The issue I described in my question occured basically due to the incompatibility of the Microsoft.Jet.OLEDB.4.0 driver in 64 bit OS.

So if we are using Microsoft.Jet.OLEDB.4.0 driver in a 64 bit server, we have to force our application to build in in 32 bit mode (This is the answer I found when I did an extensive search for this known issue) and that causes other part of my code to break.

Fortunately, now Microsoft has released a 64 bit compatible 2010 Office System Driver which can be used as replacement for the traditional Microsoft.Jet.OLEDB.4.0 driver. It works both in 32 bit as well as 64 bit servers. I have used it for Excel file manipulation and it worked fine for me in both the environments. But this driver is in BETA.

As the 2010 link is no longer available, you can currently download this driver from Microsoft Access Database Engine 2016 Redistributable

趁年轻赶紧闹 2024-08-23 12:29:48

如果问题在 ASP.NET 中仍然存在,我所要做的就是在应用程序池的高级设置中将“启用 32 位应用程序”设置更改为 True。

If the issue persist in ASP.NET,All I had to do was change the "Enable 32-bit Applications" setting to True, in the Advanced Settings for the Application Pool.

眼波传意 2024-08-23 12:29:48

我有同样的问题

Microsoft.Jet.OLEDB.4.0' 提供程序未在本地注册
机器

应用了 neo 的答案,但直到我将连接字符串中的提供程序更改为 “Provider=Microsoft.ACE.OLEDB.12.0;” 后才起作用。

如果有人遇到同样的问题,希望这会有所帮助。

I have the same problem

Microsoft.Jet.OLEDB.4.0' provider is not registered on the local
machine

I applied the answer by neo but it did not work until I change the provider to “Provider=Microsoft.ACE.OLEDB.12.0;” in connection string.

Hope this will help if some one face the same issue.

左耳近心 2024-08-23 12:29:48

我知道这是一个很老的问题,很多人已经回答过。但我总结了一些便于理解的内容:

如果文件扩展名是 xls 并且操作系统是 32 位,那么只有您可以使用“Microsoft.Jet.OLEDB.4.0”。 Microsoft 尚未发布该驱动程序的 64 位版本。

如果文件扩展名是 xlsx 或操作系统是 64 位,则必须使用“Microsoft.ACE.OLEDB.12.0”。以32/64位模式编译的应用程序不影响驱动程序的选择。

始终在 64 位操作系统上安装 Microsoft.ACE.OLEDB.12.0 的 64 位驱动程序。如果您已经安装了 Office 32 位,那么您需要使用 /passive 参数从 cmd 运行驱动程序。此黑客仅适用于 Office 2013,Microsoft 从 Office 2016 开始针对 Microsoft.ACE.OLEDB.16.0 驱动程序停止了此解决方法。

AccessDatabaseEngine_x64.exe /passive

下载驱动程序 Microsoft.ACE.OLEDB.12.0

private void ProcessFile(string path)
{
    string connString = string.Empty;

    if (Path.GetExtension(path).ToLower().Trim() == ".xls" && Environment.Is64BitOperatingSystem == false)
        connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
    else
        connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
}

如果应用程序使用 AnyCPU 标志编译,它将在 64 位操作系统上查找 64 位访问驱动程序,在 32 位操作系统上查找 32 位访问驱动程序。

I know it's quite old questions and many persons has answered. but I am summarizing the things for understanding:

If the file extension is xls and OS is 32 bit then only you can use "Microsoft.Jet.OLEDB.4.0". Microsoft has not released 64 bit version of this driver.

If file extension is xlsx or OS is 64 bit then you must have to use "Microsoft.ACE.OLEDB.12.0". The application compiled in 32/64 bit mode does not impact the selection of driver.

Always install the 64 bit driver of Microsoft.ACE.OLEDB.12.0 on OS 64 bit. If you have already installed Office 32 bit then you need to run driver from cmd with /passive argument. This hack works till Office 2013 only, Microsoft stopped this workaround from Office 2016 for Microsoft.ACE.OLEDB.16.0 drivers.

AccessDatabaseEngine_x64.exe /passive

Download drivers Microsoft.ACE.OLEDB.12.0

private void ProcessFile(string path)
{
    string connString = string.Empty;

    if (Path.GetExtension(path).ToLower().Trim() == ".xls" && Environment.Is64BitOperatingSystem == false)
        connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
    else
        connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
}

If Application is compiled with AnyCPU flag, it will look for 64 bit Access drivers on 64 bit OS and 32 bit access drivers on 32 bit OS.

懷念過去 2024-08-23 12:29:48

如果您的应用程序在 localIIS 上运行,您可以通过在 AppPool 的高级设置启用 32 位应用程序来解决此问题

在此处输入图像描述

If your application runs on localIIS, You can solve this problem by enabling 32-bit applications in AppPool's Advanced Settings

enter image description here

你怎么这么可爱啊 2024-08-23 12:29:48

我有同样的消息,我在 Visual Studio 2010 上有一个带有 do 的网页,我在该页面上读取了一个 file.xls,在我的项目视觉中没有任何问题,当我将它放在我的 IIS 本地时,给我一个 “Microsoft.Jet.OLEDB.4.0”提供程序未在本地计算机上注册'
,我接下来按照以下步骤修复了该问题,

1.-打开 IIS
2.-在高级设置
上更改应用程序池
3.-true 表示启用 32 位应用程序。

这就是全部

ps.我在 Active Solution Platform 上将配置管理器更改为 X86

I've the same message, I have a webpage with do on visual studio 2010, I read a file.xls on that page,in my project visual has not any problem, when I put it on my IIS local throw me a 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine'
,I fixed that problem next following this steps,

1.-Open IIS
2.-Change the appPool on Advanced Settings
3.-true to enable to 32-bit application.

and that's all

ps.I changed Configuration Manager to X86 on Active Solution Platform

所有深爱都是秘密 2024-08-23 12:29:48

我有同样的问题。我将应用程序配置更改为 x86,然后它就工作了!

I had the same issue. I changed the application configuration to x86, then it worked!

幻想少年梦 2024-08-23 12:29:48

我刚刚将项目属性更改为 x64 格式

项目--->属性--->构建--->目标框架---> X64

I just Changed my Property of project into x64 format

Project---> Properties--->Build--->Target Framework---> X64

扎心 2024-08-23 12:29:48

我们在桌面应用程序中遇到了这个问题。

开发环境:
Windows 7 旗舰版 - 64 位
.Net框架4.5
Provider=Microsoft.Jet.OLEDB.4.0

已通过将平台目标从任何 CPU 更改为 X86 来解决。
项目属性>>构建>>平台目标。

输入图像描述这里

We have come across this issue in desktop app.

Dev Environment:
Windows 7 Ultimate - 64 bit
.Net Framework 4.5
Provider=Microsoft.Jet.OLEDB.4.0

It has been resolved by changing Platform target to X86 from Any CPU.
Project Properties >> Build >> Platform Target.

enter image description here

云巢 2024-08-23 12:29:48

我的桌面应用程序遇到了这个问题(“Microsoft.Jet.OLEDB.4.0”提供程序未在本地计算机上注册)。我没有选择构建为 32 位应用程序。希望这能帮助处于同样情况的其他人。

我执行了以下操作,问题消失了:

  1. 安装了 64 位版本的 Microsoft Access 数据库引擎
    2010 Redistributable
    ,按照 neo 的建议

  2. 将我的提供程序更改为 Microsoft.ACE.OLEDB.12.0

I ran into this issue with my desktop application ('Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine). I did not have the option to build as a 32 bit app. Hoping this would help others in the same situation.

I did the following and the issue went away:

  1. Installed the 64 bit version of Microsoft Access Database Engine
    2010 Redistributable
    , as suggested by neo

  2. Changed my provider to Microsoft.ACE.OLEDB.12.0

向地狱狂奔 2024-08-23 12:29:48

尽管更优化的解决方案是按照上面的建议简单地重新编译,但这需要访问源代码。就我而言,我只有完成的 .exe,并且必须使用此解决方案。它使用 .Net SDK 中的 CorFlags.exe 来更改应用程序的加载特性。

  1. 下载.Net Framework SDK(我个人使用3.5,但使用的版本应等于或高于您的应用程序所需的 .Net
  2. 安装时,您需要的只是 CorLibs.exe,因此只需选中 Windows Development Tools。 。
  3. 安装后,找到您的 CorFlags.exe,对于我安装的 .Net Framework 3.5 SDK,它位于 C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin
  4. 打开命令提示符并输入 path/to/CorFlags.exe path/to/your/exeFile.exe /32Bit+

您就完成了!以便它以 32 位 WOW64 模式启动,因此可以访问 microsoft.jet.oledb.4.0。

Although a more optimal solution is to simply recompile as suggested above, that requires access to the source code. In my case, I only had the finished .exe and had to use this solution. It uses CorFlags.exe from the .Net SDK to change the loading characteristics of the application.

  1. Download the .Net Framework SDK (I personally used 3.5, but the version used should be at or above the required .Net for your application.
  2. When installing, all you need is CorLibs.exe, so just check Windows Development Tools.
  3. After installation, find your CorFlags.exe. For my install of the .Net Framework 3.5 SDK, it was at C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin.
  4. Open a command prompt and type path/to/CorFlags.exe path/to/your/exeFile.exe /32Bit+.

You're done! This sets the starting flags for your program so that it starts in 32 bit WOW64 mode, and can therefore access microsoft.jet.oledb.4.0.

别挽留 2024-08-23 12:29:48

只需将连接字符串中的 Microsoft.Jet.OLEDB.4.0 替换为 Microsoft.ACE.OLEDB.12.0

Just replace Microsoft.Jet.OLEDB.4.0 with Microsoft.ACE.OLEDB.12.0 in your connection string

萌吟 2024-08-23 12:29:48

更改 IIS 设置应用程序池高级设置。启用 32 位应用程序

Change in IIS Settings application pool advanced settings.Enable 32 bit application

陌路黄昏 2024-08-23 12:29:48

只需根据您的机器更改属性即可,所有操作都已完成:-)

项目--->属性--->构建--->目标框架---> X64

项目--->属性--->构建--->目标框架---> X86

Just Change the property based on your machine and all have done :-)

Project---> Properties--->Build--->Target Framework---> X64

or

Project---> Properties--->Build--->Target Framework---> X86

疏忽 2024-08-23 12:29:48

我已将连接字符串从

var myConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Persist Security Info=True;Jet OLEDB:Database Password=;",gisdbPath);

更改为对此:

var myConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Deny None;Data Source={0};user id=Admin;password=;", gisdbPath);

它对我来说从来没有要求注册 Microsoft.Jet.OLEDB.4.0'。

I have changed my connection string from

var myConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Persist Security Info=True;Jet OLEDB:Database Password=;",gisdbPath);

to this:

var myConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Deny None;Data Source={0};user id=Admin;password=;", gisdbPath);

It works fro me never asked for Microsoft.Jet.OLEDB.4.0'registered.

述情 2024-08-23 12:29:48

Jet 确实没有 64 位版本 - 并且(显然)没有计划生产该版本。

您也许可以使用 ACE 64 位驱动程序:
http://www.microsoft.com/en -us/download/details.aspx?displaylang=en&id=23734

  • 但我不知道如果您需要返回 Jet 来获取 32 位应用程序,这将如何工作。

但是,您也许可以在 Express 版本中将项目切换为 32 位(我还没有尝试过,也不再安装任何版本的 2008),

也许是时候完全放弃 Access 数据库,硬着头皮转而使用 SQL Server 了?

There is indeed no 64 bit version of Jet - and no plans (apparently) to produce one.

You might be able to use the ACE 64 bit driver:
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=23734

  • but I have no idea how that would work if you need to go back to Jet for your 32 bit apps.

However, you may be able to switch the project to 32bit in the Express version (I haven't tried and don't have 2008 installed in any flavour anymore)

Maybe it's time to scrap Access databases altogether, bite the bullet and go for SQL server instead?

几度春秋 2024-08-23 12:29:48

我正在使用 VS2013 for Winforms,以下解决方案对我有用。

I'm using VS2013 for Winforms, the below solution worked for me.

-黛色若梦 2024-08-23 12:29:48

在旧版本的 IIS 中,您找不到高级设置,因此要启用启用 32 位应用程序,您必须执行以下命令:

cscript %SYSTEMDRIVE%\ inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

参考:此处

In older versions of IIS, you will not find Advance Settings so to enable Enable 32-bit Applications you have to execute the following commands:

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

and

%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

Reference : Here

陌上芳菲 2024-08-23 12:29:48

在 Windows 8.1 上运行“SQL Server 2014 导入和导出数据(64 位)”时,我遇到了同样的异常。

为了解决此问题,我已执行以下操作

启动 SQL Server 2014 导入和导出数据(32 位)而不是 64 位,它对我有用。我没有更改任何 IIS 设置,也没有安装任何额外的软件。

I was getting same exception while running "SQL Server 2014 Import and Export Data (64-bit)" on my Windows 8.1.

To fix the issue this issue I have done the following

started SQL Server 2014 Import and Export Data (32-bit) instead of 64-bit and it is working for me. I haven't changed any IIS setting and not installed any extra software.

笑红尘 2024-08-23 12:29:48

我知道当我在新服务器上部署应用程序时,我会一遍又一遍地遇到此问题,因为我正在使用此驱动程序连接到 Excel 文件。这就是我最近在做的事情。

有一台 Windows Server 2008 R2,我为 x64 位机器安装了 Access 驱动程序,然后我摆脱了这条消息,这让我很高兴遇到另一条消息。

下面这个在我的开发机器上运行得非常好,但在服务器上即使安装了最新的 ODBC 驱动程序也会出现错误,我认为这就是问题所在,但这就是我解决它的方法。

private const string OledbProviderString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\OlsonWindows.xls;Extended Properties=\"Excel 8.0;HDR=YES\"";

我用如下所示的新提供程序替换:

private const string OledbProviderString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\OlsonWindows.xlsx;Extended Properties='Excel 12.0;HDR=YES;';";

但当我这样做时,您应该注意一件事。使用 .xlsx 文件扩展名,Excel 版本为 12.0。

当我收到此错误消息错误:“无法找到可安装的 ISAM” 后,我决定更改一些内容,如下所示:

private const string OledbProviderString =      @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\OlsonWindows.xls;Extended Properties='Excel 8.0;HDR=YES;';"; 

是的,我已经完成了那个令人讨厌的事情,但是在这里我收到另一条消息Microsoft Access 数据库引擎无法打开或写入文件“time_zone”。它已经被另一个用户以独占方式打开,或者您需要查看和写入其数据的权限。 这告诉我,我离解决这个问题已经不远了。

也许有另一个进程同时打开了该文件,我所要做的就是重新启动,一切都会按预期顺利启动。

I know that I have this problem over and over when I deploy my application on a new server because I'm using this driver to connect to a Excel file. So here it is what I'm doing lately.

There's a Windows Server 2008 R2, I install the Access drivers for a x64 bit machine and I get rid of this message, which makes me very happy just to bump into another.

This one here below works splendidly on my dev machine but on server gives me an error even after installing the latest ODBC drivers, which I think this is the problem, but this is how I solved it.

private const string OledbProviderString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\OlsonWindows.xls;Extended Properties=\"Excel 8.0;HDR=YES\"";

I replace with the new provider like this below:

private const string OledbProviderString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\OlsonWindows.xlsx;Extended Properties='Excel 12.0;HDR=YES;';";

But as I do this, there's one thing you should notice. Using the .xlsx file extension and Excel version is 12.0.

After I get into this error message Error: "Could Not Find Installable ISAM", I decide to change the things a little bit like below:

private const string OledbProviderString =      @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\OlsonWindows.xls;Extended Properties='Excel 8.0;HDR=YES;';"; 

and yes, I'm done with that nasty thing, but here I got another message The Microsoft Access database engine cannot open or write to the file 'time_zone'. It is already opened exclusively by another user, or you need permission to view and write its data. which tells me I'm not far away from solving it.

Maybe there's another process that opened the file meanwhile and all that I have to do is a restart and all will take start smoothly running as expected.

蘑菇王子 2024-08-23 12:29:48

转到“开始”->“运行”并输入 cmd
这将启动命令提示符
(也可以从“开始”->“程序”->“附件”->“命令提示符”)

输入 cd .. 并按 Return 键
输入 cd .. 并再次按回车键(继续执行此操作,直到提示显示 :> )

现在您需要转到一个特殊文件夹,可能是 c:\windows\system32 或 c:\winnt\system32 或它可能是 c:\windows\sysWOW64
尝试输入这些例如
cd c:\windows\sysWOW64
(如果提示“系统找不到指定的路径,请尝试下一个”)
cd c:\windows\system32
cd c:\winnt\system32
当其中之一没有导致错误时,停止,您已经找到了正确的文件夹。

之后按回车键来注册 OLE DB 4.0 DLL

现在您需要通过键入这些命令并在每个regsvr32 Msjetoledb40.dll
regsvr32 Msjet40.dll
regsvr32 Mswstr10.dll
regsvr32 Msjter40.dll
regsvr32 Msjint40.dll

go to Start->Run and type cmd
this starts the Command Prompt
(also available from Start->Programs->Accessories->Command Prompt)

type cd .. and press return
type cd .. and press return again (keep doing this until the prompt shows :> )

now you need to go to a special folder which might be c:\windows\system32 or it might be c:\winnt\system32 or it might be c:\windows\sysWOW64
try typing each of these eg
cd c:\windows\sysWOW64
(if it says The system cannot find the path specified, try the next one)
cd c:\windows\system32
cd c:\winnt\system32
when one of those doesn't cause an error, stop, you've found the correct folder.

now you need to register the OLE DB 4.0 DLLs by typing these commands and pressing return after each

regsvr32 Msjetoledb40.dll
regsvr32 Msjet40.dll
regsvr32 Mswstr10.dll
regsvr32 Msjter40.dll
regsvr32 Msjint40.dll

好多鱼好多余 2024-08-23 12:29:48

Jet 没有 64 位提供程序。如果您想要支持多个数据库源(包括 Jet to Excel),您至少需要应用程序的该部分在 32 位进程中运行。

当你为 x86 编译时遇到的错误有点奇怪。我不明白在这种情况下您将如何最终引用 64 位程序集。

There isn't a 64 bit provider for Jet. If you want to support multiple DB sources including Jet to Excel you will need at least that part of your application to run in a 32 bit process.

The error you are getting when you compile for x86 is a bit strange. I can't see how you would end up referencing 64 bit assemblies in this case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文