.net 我们可以将“Microsoft.ACE.Oledb.12.0.dll”的引用添加到项目中吗

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18380388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:25:14  来源:igfitidea点击:

Can we add Reference of 'Microsoft.ACE.Oledb.12.0.dll' to project

.netdatabaseoledboledbconnection

提问by Avinash

I am getting error "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine." on my testing servers. So My Question is :

我收到错误“'Microsoft.ACE.OLEDB.12.0' 提供程序未在本地计算机上注册。” 在我的测试服务器上。所以我的问题是:

i) Can i add reference for "'Microsoft.ACE.Oledb.12.0.dll'" to project it self? ii) Is it safe? iii) How to do this?

i) 我可以添加对“'Microsoft.ACE.Oledb.12.0.dll'”的引用来自行投影吗?ii) 安全吗?iii) 如何做到这一点?

Every thing is working on my local machine since i have latest version of office install in my machine. As soon as i am deploying my code to testing servers i am getting above error. I might not be able to install Office on testing servers (Due to some reason). So is it possible to put all require dll in project itself and deploy that to testing servers too ?

一切都在我的本地机器上运行,因为我在我的机器上安装了最新版本的 Office。一旦我将代码部署到测试服务器,我就会遇到上述错误。我可能无法在测试服务器上安装 Office(由于某种原因)。那么是否可以将所有需要的 dll 放在项目本身中并将其部署到测试服务器上?

Thanks in advance.

提前致谢。

回答by Don Vince

In order to use "Microsoft.ACE.OLEDB.12" you need to install the "Microsoft Access Database Engine 2010 Redistributable"

为了使用“Microsoft.ACE.OLEDB.12”,您需要安装“Microsoft Access Database Engine 2010 Redistributable”

The information page for this is here: http://www.microsoft.com/en-us/download/details.aspx?id=13255

信息页面在这里:http: //www.microsoft.com/en-us/download/details.aspx?id=13255

And as @user1297578 quite rightly noted the actual download is here: http://www.microsoft.com/en-in/download/confirmation.aspx?id=13255

正如@user1297578 非常正确地指出,实际下载在这里:http: //www.microsoft.com/en-in/download/confirmation.aspx?id=13255

Once you have installed that, the actual assembly is called ACEOLEDB.DLL, the following command at a Command Prompt will find it for you on your system:

安装后,将调用实际程序集ACEOLEDB.DLL,命令提示符处的以下命令将在您的系统上为您找到它:

C:\>DIR /s/b c:\ACEOLEDB.DLL
c:\Program Files\Common Files\Microsoft Shared\OFFICE14\ACEOLEDB.DLL

For reference, the following is the error message I received from a program until I installed the above redistributable:

作为参考,以下是我从程序中收到的错误消息,直到我安装了上述可再发行组件:

Connection Failed. 
Error from IDataInitialize::GetDataSource
with connectionString=Data Source=C:\MyFileName.mdb;Mode=Share Deny Write;Provider=Microsoft.ACE.OLEDB.12.0;User Id=admin
OLE DB Error Report:
    ErrorRecord:
    Hresult=80040154
    Description: Class not registered
    SQLErrorInfo: No error info available
    Source: Microsoft OLE DB Service Components

回答by Haider Abbas

You can get around your problem by adding Microsoft Access Database Engine 2010 as prerequisites in Setup project, The following link shows you how to do so, but be careful, if you use VS2017 then the path is different, the path for VS2017 is:

您可以通过在安装项目中添加 Microsoft Access Database Engine 2010 作为先决条件来解决您的问题,以下链接向您展示了如何执行此操作,但请注意,如果您使用 VS2017 则路径不同,VS2017 的路径为:

"C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages"

“C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages”

not

不是

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages"

“C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages”

Also I noticed that in some cases you have to install "AccessDatabaseEngine.exe" not "AccessDatabaseEngine_X64.exe" on user's machine, even if it is a 64-bit windows!!!

我还注意到,在某些情况下,即使是 64 位 Windows,您也必须在用户计算机上安装“AccessDatabaseEngine.exe”而不是“AccessDatabaseEngine_X64.exe”!!!

Here is the article including a video showing how to do all this in a step by step:

这是一篇包含视频的文章,该视频展示了如何逐步完成所有这些操作:

https://csharp-tutorials1.blogspot.com/2017/12/add-microsoft-access-engine-2010-as.html

https://csharp-tutorials1.blogspot.com/2017/12/add-microsoft-access-engine-2010-as.html

Best regards

此致

回答by user3321978

If you want use AccessDatabaseEngine 64 and IIS 64 bit (example windows 2012 64bit), then follow

如果你想使用 AccessDatabaseEngine 64 和 IIS 64 位(例如 windows 2012 64 位),然后按照

  1. You must add role asp.net 4.0, .net 4.0 on IIS

  2. Open IIS Manager

  3. Open your site's application pool's advenced setting

  4. Enable 32-bit Applications set to False (must do this, or not iis set to 32 bit engine)

  5. if your site use .net 4.0, then .NET Framework version set to exactly version

  1. 您必须在 IIS 上添加角色 asp.net 4.0、.net 4.0

  2. 打开 IIS 管理器

  3. 打开您站点的应用程序池的高级设置

  4. 启用 32 位应用程序设置为 False(必须这样做,否则 iis 设置为 32 位引擎)

  5. 如果您的站点使用 .net 4.0,则 .NET Framework 版本设置为完全版本

6. [this is keypoint!!!] Managed Pipeline Mode set to "Classic"

6. [这是关键点!!!] Managed Pipeline Mode 设置为“Classic”

good luck :)

祝你好运 :)

回答by Krzysztof Madej

To use this lib you need installed Office on computer. If have one you can simply add lib in typical way.

要使用此库,您需要在计算机上安装 Office。如果有一个,您可以简单地以典型方式添加 lib。