提供者与Oracle客户端版本不兼容
我尝试在 ASP.net 项目上使用 Oracle ODP.NET 11g (11.1.0.6.20) Instant Client 作为数据提供程序,但是当我运行我收到一条“提供程序与 Oracle 客户端版本不兼容”错误消息。 任何帮助,将不胜感激。
我在 Visual Studio 2005 中引用了数据提供程序,后面的代码如下所示:
using Oracle.DataAccess.Client;
..
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString =
"Data Source=MyOracleServerName;" +
"Integrated Security=SSPI";
oOracleConn.Open();
//Do Something
oOracleConn.Close();
页面的错误如下所示:
Exception Details: Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client
Source Error:
Line 21:
Line 22:
Line 23: OracleConnection oOracleConn = new OracleConnection();
Line 24: oOracleConn.ConnectionString =
Line 25: "Data Source=MyOracleServerName;" +
[OracleException (0x80004005): The provider is not compatible with the version of Oracle client]
Oracle.DataAccess.Client.OracleInit.Initialize() +494
Oracle.DataAccess.Client.OracleConnection..cctor() +483
Stack Trace:
[TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.]
Oracle.DataAccess.Client.OracleConnection..ctor() +0
Boeing.IVX.Web.RoyTesting.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\CE218C\Desktop\IVX.Net\Web\IVX\RoyTesting.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
I'm trying to use the Oracle ODP.NET 11g (11.1.0.6.20) Instant Client on my ASP.net project as a Data Provider but when I run the aspx page I get a "The provider is not compatible with the version of Oracle client" error message. Any help would be appreciated.
I've referenced the Data Provider in Visual Studio 2005 and the code behind looks like this:
using Oracle.DataAccess.Client;
..
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString =
"Data Source=MyOracleServerName;" +
"Integrated Security=SSPI";
oOracleConn.Open();
//Do Something
oOracleConn.Close();
The error for the page looks like this:
Exception Details: Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client
Source Error:
Line 21:
Line 22:
Line 23: OracleConnection oOracleConn = new OracleConnection();
Line 24: oOracleConn.ConnectionString =
Line 25: "Data Source=MyOracleServerName;" +
[OracleException (0x80004005): The provider is not compatible with the version of Oracle client]
Oracle.DataAccess.Client.OracleInit.Initialize() +494
Oracle.DataAccess.Client.OracleConnection..cctor() +483
Stack Trace:
[TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.]
Oracle.DataAccess.Client.OracleConnection..ctor() +0
Boeing.IVX.Web.RoyTesting.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\CE218C\Desktop\IVX.Net\Web\IVX\RoyTesting.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(28)
我一直在进一步研究这个问题,您只需从同一下载版本的 ODP.Net 中获取所有适当的 DLL,并将它们放在与您的 Exe 文件相同的文件夹中,因为 ODP.Net 很挑剔不混合版本号。
我已经在这里解释了如何执行此操作: http ://splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c
不过,要点如下:
I've been looking into this problem further, and you simply need to grab all the appropriate DLL's from the same downloaded version of ODP.Net and put them in the same folder as your Exe file, because ODP.Net is fussy about not mixing version numbers.
I've explained how to do this here: http://splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c
Here's the gist of it though:
您应该“忽略”这里针对初学者的所有 x86/x64 讨论,而是尝试 ODP.NET 托管驱动程序(如果您使用的是 .Net v4+):
https://www.nuget.org/packages/Oracle.ManagedDataAccess/
https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/
Oracle ODP.net 托管与非托管驱动程序
避免所有“非托管”什么 DLL 什么架构问题! :D(关于 Oracle 时间)。
NuGet 包(也适用于 11g):
< img src="https://i.sstatic.net/i7l0w.png" alt="在此处输入图像描述">
旧/手动方法:
有关如何转换为使用托管库的信息:
You should "ignore" all the x86/x64 talk here for starters and instead try the ODP.NET Managed Driver (if you are using .Net v4+):
https://www.nuget.org/packages/Oracle.ManagedDataAccess/
https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/
Oracle ODP.net Managed vs Unmanaged Driver
Avoid all the "unmanaged" what DLL what architecture issues! :D (about time Oracle).
The NuGet package (also works for 11g):
The old / manual method:
For info on how to convert to using the managed libraries:
我只安装了 Oracle Data Provider for .NET 2.0 (11.1.0.6.20),而没有安装 Oracle Instant Client (11.1.0.6.0)。
我刚刚安装了它,错误消失了!
I only installed the Oracle Data Provider for .NET 2.0 (11.1.0.6.20) and I did not install the Oracle Instant Client (11.1.0.6.0).
I just installed it and the error disappeared!
这可能是由于针对 32 位 Oracle 客户端运行 64 位 .NET 运行时造成的。 如果您的服务器运行的是 64 位应用程序,则可能会发生这种情况。 它将使用 64 位运行时运行 .NET 应用程序。 您可以在 VS 中设置项目的 CPU 标志以在 32 位运行时运行。
This can be caused by running a 64bit .NET runtime against a 32bit Oracle client. This can happen if your server you are running the app on it 64 bit. It will run the .NET app with the 64bit runtime. You can set the CPU flag on your project in VS to run in the 32bit runtime.
让我们做一些总结:
错误消息“提供程序与Oracle客户端的版本不兼容”可能由多种原因引起。 同时,错误消息可能有不同的风格,例如“未将对象引用设置为对象的实例。”或“无法加载文件或程序集“Oracle.DataAccess”或其中之一它的依赖项”
Oracle Data Provider for .NET(ODP.NET,即文件
Oracle.DataAccess.dll
)不包含在 Oracle Instant Client 中,必须单独安装(从 32 位 Oracle 数据访问组件 (ODAC) 或 64 位 Oracle 数据访问组件 (ODAC) 下载),否则您必须在 Oracle Universal Installer (OUI) 中选择相应的选项。请注意,当安装 Oracle Data Provider >= 12.1 时,该提供程序不会自动注册到 GAC 中。 如果需要,您必须手动注册,请参阅 Oracle Doc 2272241.1。
ODP.NET 的版本与安装的 Oracle 客户端版本不匹配。 即使是次要版本号也必须检查! 例如,
Oracle.DataAccess.dll
版本 4.112.3.0 与 Oracle 客户端 11.2.0.4 不兼容。 仔细检查ODP.NET和Oracle Client的版本。 您可以在oraociei*.dllsigcheck code> 和/或
OraOps*w.dll
来获取 Oracle 客户端的版本。注意不同的编号方案。 文件版本 4.112.3.0 表示:.NET Framework 版本 4、Oracle 版本 11.2.0.3.x。
ODP.NET 版本有“1.x”、“2.x”和“4.x”。 这些数字与 Microsoft .NET Framework 版本 1.0.3705/1.1.4322、2.0.50727 和 4.0.30319 相关。 版本“1.x”在 Oracle Client 11.1 之前可用。 版本“4.x”随 Oracle Client 11.2 一起引入
ODP.NET 的体系结构(32 位或 64 位)与您的应用程序体系结构不匹配。 32 位应用程序仅适用于 32 位 Oracle Client/ODP.NET,64 位应用程序则需要 64 位 Oracle Client/ODP.NET。 (除非您使用ODP.NET托管驱动程序)
.NET Framework 版本不匹配。 例如,如果您使用 Target .NET Framework 2.0 编译应用程序,则无法使用 ODP.NET 版本 4.x。 .NET Framework 目标版本必须等于或高于 ODP.NET 版本。
您的开发计算机上的
Oracle.DataAccess.dll
版本(即编译时加载的版本)高于目标计算机上的版本。请注意,
Oracle.DataAccess.dll
可能会从 GAC< 加载/a> 默认情况下优先于任何本地提供的文件。较新版本的 ODP.NET 需要更高的 Microsoft .NET Framework 版本。 例如,ODP.NET 版本 21.4 需要 .NET Framework 4.8。 检查您版本的“.NET 数据提供程序开发人员指南”中的系统要求。
解决方案
考虑使用ODP.NET托管驱动程序,它可以从Oracle页面下载:64 位 Oracle 数据访问组件 (ODAC) 下载。
您只需将 Oracle.ManagedDataAccess.dll 文件复制到应用程序目录即可,无需其他任何操作。 它适用于 32 位和 64 位。
在您的
*.csproj
中,分别。*.vbproj
编辑对 ODP.NET 的引用,如下所示:不需要
Version=...
或processorArchitecture=...
等属性。您的应用程序将根据所选体系结构和目标 .NET 框架加载正确的
-> 未 100% 验证Oracle.DataAccess.dll
(前提是安装正确)如果您不知道目标计算机上 Oracle 客户端的版本(例如,它可能是您客户的计算机):转到上述下载页面并下载最低版本的XCopyOracle.DataAccess.dll 文件复制到本地计算机。 在您的 VS 项目中引用此(很可能已过时)DLL。 此 DLL 的版本是您的应用程序可以使用的 ODP.NET 的最低版本。 当您运行应用程序时,GAC 中的发布者策略将重定向到实际安装的版本。
我认为将单个 DLL 复制到某些文件夹并不是明智的做法。 它可能在“裸”机器上运行,但如果您的目标机器安装了任何 Oracle 产品,则版本不匹配的风险很高。 从您的计算机中卸载所有 Oracle 产品并进行全新安装。 看看如何卸载/完全删除Oracle 11g(客户端)? 它是为了获得一台真正干净的机器。
如果您必须同时使用 32 位和 64 位应用程序,请按照以下说明在一台计算机上安装两个版本:
假设:Oracle Home 名为
OraClient11g_home1
,客户端版本为 11gR2。可以选择删除任何已安装的 Oracle 客户端
下载并安装 Oracle x86 客户端,例如安装到
C:\Oracle\11.2\Client_x86
下载 Oracle x64 客户端并安装到不同文件夹,例如安装到
C:\Oracle\11.2 \Client_x64
打开命令行工具,转到文件夹 %WINDIR%\System32,通常
C :\Windows\System32
并创建到文件夹C:\Oracle\11.2\Client_x64
的符号链接ora112
(见下文)更改为文件夹 %WINDIR%\SysWOW64,通常为
C:\Windows\SysWOW64
并创建符号链接ora112
到文件夹C:\Oracle\11.2\Client_x86
,(见下文)修改
PATH
环境变量,替换所有条目,如C:\Oracle\11.2\Client_x86
和C:\ Oracle\11.2\Client_x64
byC:\Windows\System32\ora112
,各自的\bin
子文件夹。 注意:C:\Windows\SysWOW64\ora112
不得位于 PATH 环境中。如果需要,将您的
ORACLE_HOME
环境变量设置为C:\Windows\System32\ora112
打开注册表编辑器。 将注册表值
HKLM\Software\ORACLE\KEY_OraClient11g_home1\ORACLE_HOME
设置为C:\Windows\System32\ora112
设置注册表值
HKLM\Software\Wow6432Node\ ORACLE\KEY_OraClient11g_home1\ORACLE_HOME
到C:\Windows\System32\ora112
(不是C:\Windows\SysWOW64\ora112
)你完成了! 现在您可以无缝地一起使用 x86 和 x64 Oracle 客户端,即 x86 应用程序将加载 x86 库,x64 应用程序加载 x64 库,而无需对系统进行任何进一步修改。
创建符号链接的命令:
一些注意事项:
两个符号链接必须具有相同的名称,例如
ora112
。如果您想随后手动安装 ODP.NET,请注意选择适当的文件夹进行安装。
尽管名称不同,文件夹
C:\Windows\System32
包含 x64 库,而C:\Windows\SysWOW64
包含 x86(32 位)库。 不要混淆。也许将您的
TNS_ADMIN
环境变量(分别是注册表中的TNS_ADMIN
条目)设置为公共位置是一个明智的选择,例如TNS_ADMIN=C :\Oracle\Common\network
。Let's make some kind of summary:
Error message "The provider is not compatible with the version of Oracle client" can be caused by several reasons. Meanwhile the error message can have different flavors, e.g. "Object reference not set to an instance of an object." or "Could not load file or assembly 'Oracle.DataAccess,' or one of its dependencies"
Oracle Data Provider for .NET (ODP.NET, i.e. file
Oracle.DataAccess.dll
) is not included in Oracle Instant Client, it has to be installed separately (download from 32-bit Oracle Data Access Components (ODAC) or 64-bit Oracle Data Access Components (ODAC) Downloads) or you have to select according option in Oracle Universal Installer (OUI).Note, when installing the Oracle Data Provider >= 12.1, then the provider is not automatically registered into GAC. You have to register it manually if needed, see Oracle Doc 2272241.1.
The version of ODP.NET does not match installed version of Oracle Client. You have to check even the minor version number! For example,
Oracle.DataAccess.dll
Version 4.112.3.0 is not compatible with Oracle Client 11.2.0.4. Check versions of ODP.NET and Oracle Client carefully. You can use sigcheck onoraociei*.dll
and/orOraOps*w.dll
to get version of Oracle Client.Be aware of different numbering scheme. File version 4.112.3.0 means: .NET Framework Version 4, Oracle Release 11.2.0.3.x.
There are ODP.NET version "1.x", "2.x" and "4.x". These numbers are related to Microsoft .NET Framework versions 1.0.3705/1.1.4322, 2.0.50727 and 4.0.30319. Version "1.x" was available until Oracle Client 11.1. Version "4.x" was introduced with Oracle Client 11.2
The architecture (32bit or 64bit) of ODP.NET does not match your application architecture. A 32bit application works only with 32bit Oracle Client/ODP.NET respectively a 64bit application requires 64bit Oracle Client/ODP.NET. (Unless you use ODP.NET Managed Driver)
The .NET Framework version do not match. For example, if you compile your application with Target .NET Framework 2.0 then you cannot use ODP.NET version 4.x. The .NET Framework target version must be equal or higher than version of ODP.NET.
The version of
Oracle.DataAccess.dll
on your development machine (i.e. the version which is loaded while compiling) is higher than the version on the target machine.Be aware that
Oracle.DataAccess.dll
might be loaded from GAC which by default takes precedence over any locally provided file.Newer release of ODP.NET requires higher Microsoft .NET Framework version. For example ODP.NET version 21.4 requires .NET Framework 4.8. Check the System Requirements in the "Data Provider for .NET Developer's Guide" of your release.
Solutions
Consider to use the ODP.NET Managed Driver, it can be downloaded from Oracle page: 64-bit Oracle Data Access Components (ODAC) Downloads.
There you only have to copy
Oracle.ManagedDataAccess.dll
file to your application directory, nothing else is required. It works for both 32bit and 64bit.In your
*.csproj
, resp.*.vbproj
edit your reference to ODP.NET like this:Attributes like
Version=...
orprocessorArchitecture=...
are not required.Your application will load the correct
-> not 100% verifiedOracle.DataAccess.dll
depending on selected architecture and target .NET framework (provided that it is installed properly)In case you do not know the version of Oracle Client on target machine (e.g. it might be the machine of your customer): Go to the download page mentioned above and download the least XCopy version of Oracle Data Access Components. Extract the zip and copy just the
Oracle.DataAccess.dll
file to your local machine. In your VS project make a reference to this (most likely outdated) DLL. The version of this DLL is the least version of ODP.NET your application will work with. When you run your application then the Publisher Policy in GAC will redirect to actually installed version.I don't think it is a smart approach to take single DLL's and copy them to certain folders. It may work on a "naked" machine but if your target machine has installed any Oracle products there is a high risk for version mismatch. Uninstall any Oracle products from your machine and make a fresh installation. Have a look at How to uninstall / completely remove Oracle 11g (client)? it order to get a really clean machine.
In case you have to work with 32bit and 64bit applications at the same time, follow this instruction to install both versions on one machine:
Assumptions: Oracle Home is called
OraClient11g_home1
, Client Version is 11gR2.Optionally remove any installed Oracle client
Download and install Oracle x86 Client, for example into
C:\Oracle\11.2\Client_x86
Download and install Oracle x64 Client into different folder, for example to
C:\Oracle\11.2\Client_x64
Open command line tool, go to folder %WINDIR%\System32, typically
C:\Windows\System32
and create a symbolic linkora112
to folderC:\Oracle\11.2\Client_x64
(see below)Change to folder %WINDIR%\SysWOW64, typically
C:\Windows\SysWOW64
and create a symbolic linkora112
to folderC:\Oracle\11.2\Client_x86
, (see below)Modify the
PATH
environment variable, replace all entries likeC:\Oracle\11.2\Client_x86
andC:\Oracle\11.2\Client_x64
byC:\Windows\System32\ora112
, respective their\bin
subfolder. Note:C:\Windows\SysWOW64\ora112
must not be in PATH environment.If needed set yor
ORACLE_HOME
environment variable toC:\Windows\System32\ora112
Open your Registry Editor. Set Registry value
HKLM\Software\ORACLE\KEY_OraClient11g_home1\ORACLE_HOME
toC:\Windows\System32\ora112
Set Registry value
HKLM\Software\Wow6432Node\ORACLE\KEY_OraClient11g_home1\ORACLE_HOME
toC:\Windows\System32\ora112
(notC:\Windows\SysWOW64\ora112
)You are done! Now you can use x86 and x64 Oracle client seamless together, i.e. an x86 application will load the x86 libraries, an x64 application loads the x64 libraries without any further modification on your system.
Commands to create symbolic links:
Some notes:
Both symbolic links must have the same name, e.g.
ora112
.In case you want to install ODP.NET manually afterwards, take care to select appropriate folders for installation.
Despite of their names folder
C:\Windows\System32
contains the x64 libraries, whereasC:\Windows\SysWOW64
contains the x86 (32-bit) libraries. Don't be confused.Maybe it is a wise option to set your
TNS_ADMIN
environment variable (resp.TNS_ADMIN
entries in Registry) to a common location, for exampleTNS_ADMIN=C:\Oracle\Common\network
.经过几个小时的故障排除,我发现这个问题是由于我的项目 bin 目录中存在 Oracle.DataAccess.dll (v4.0),但运行时还从 GAC 加载 Oracle.DataAccess.dll (v2.x) 引起的。 删除并读取项目引用中的 Oracle.DataAccess 条目解决了我的问题。
这里提到的其他文件在我的情况下似乎没有必要。
更新
“提供程序与 Oracle 客户端的版本不兼容”错误的根本原因(通常)是托管程序集尝试加载与版本不匹配的非托管库。 看来您可以通过在 web.config1
After several hours of troubleshooting, I found this issue to be caused by having Oracle.DataAccess.dll (v4.0) in my projects bin directory, but the runtime also loading Oracle.DataAccess.dll (v2.x) from the GAC. Removing and readding the Oracle.DataAccess entry in the project references solved the problem for me.
The other files mentioned here did not appear to be necessary in my situation.
UPDATE
The root cause of the "The provider is not compatible with the version of Oracle client" error is (generally) that the managed assembly is attempting to load unmanaged libraries which do not match versions. It appears you can force the Oracle driver to use the correct libraries by specifying the library path in the web.config1
在目标计算机上安装 ODP.Net,它应该可以解决问题...复制 dll 看起来不是一个好主意...
install ODP.Net on the target machine and it should solve the issue... copying the dll's does not look a good idea...
对于 Oracle 11g (11.1.0.7.20),我必须添加以下 dll 和我的 Exe 才能工作。
For Oracle 11g (11.1.0.7.20) I had to add the following dlls along with my Exe to work.
在我看来,虽然您有带有 Oracle Istant 客户端的 ODP,但 ODP 可能会尝试使用实际的 Oracle 客户端。 您的计算机上是否还安装了标准 Oracle 客户端? 我记得 Oracle 对于同一台机器上的多个客户端非常挑剔。
It would seem to me that though you have ODP with the Oracle Istant Client, the ODP may be trying to use the actual Oracle Client instead. Do you have a standard Oracle client installed on the machine as well? I recall Oracle being quite picky about when it came to multiple clients on the same machine.
我有同样的问题,但就我而言,我不能只是将 dll 复制到 bin 文件夹中,然后我只能“重新绑定”程序集版本。
i have the same problem but in my case i can't just copy the dlls into the bin folder, then i only 'rebind' the assembly version.
以下是我为解决这个持续了 3 个小时的问题所做的操作:
在位于
C:\oracle\product\11.2.0
的 Oracle 主目录下,我有一个名为client_1< /code> 我之前在其中安装了适用于 Windows 64 位的
ODP.NET
位。后来在尝试使用 Visual Studio 2012 调试我的 ASP.NET Web API 应用程序时,我不断收到此错误消息:提供程序与 Oracle 客户端的版本不兼容
搜索 Google 我发现发生这种情况是因为我使用的是
ODP.NET
64 位。 然后我抓取了适用于 Windows 32 位的ODP.NET
并安装了它,但我不断收到相同的错误消息。解决方案:删除文件夹
client_1
并重新安装ODP.NET
32 位。 安装程序在某种程度上将 64 位版本与 32 位版本混合在一起。 想想看...现在我又高兴了,我可以打开一个新的
OracleConnection
。 最后! :)Here's what I did to solve this problem that persisted for 3 long hours:
Under Oracle home located at
C:\oracle\product\11.2.0
I had a folder calledclient_1
where I had previously installedODP.NET
bits for Windows 64 bits.Later while trying to debug my ASP.NET Web API app with Visual Studio 2012, I kept getting this error message: The provider is not compatible with the version of Oracle client.
Searching Google I found that this was happening because I was using
ODP.NET
64 bits. Then I grabbedODP.NET
for Windows 32 bits and installed it but I kept getting the same error message.SOLUTION: deleted the folder
client_1
and resinstalledODP.NET
32 bits. Somewhat the installer was mixing bits from the 64 bit version with the 32 bit version. Go figure...Now I'm happy again and I can open a new
OracleConnection
. FINALLY! :)TLDR 版本:
完整版本:
首先,让我们确保我们了解旧的非托管提供程序(而不是新的 12c 100% 托管提供程序)的组件。 它由两部分组成:
简而言之,Oracle.DataAccess.dll 几乎只是一个包装器,将 .net 指令转换为 ORACLE-NET 指令对于非托管客户端。
也就是说,当您加载 Oracle.DataAccess 时,它会按照一定的顺序尝试查找所需的非托管客户端 dll。 来自 Oracle 文档:
因此,在您的情况下,您的应用程序遵循上述过程并找到了一个包含未托管 dll 的路径,这些 dll 相对于您正在使用的 Oracle.DataAccess.dll 程序集来说太旧了。
可能只是该计算机上安装的唯一 Oracle 客户端太旧了。 但是,如果您在计算机上安装了多个客户端,并且首先在不同但较旧的安装中找到了非托管文件,那么这一点就会发挥作用。 如果是后者,简单的做法是在配置中使用 dllPath 配置变量并将其指向正确的 Oracle Home Bin 文件夹:
如果要安装客户端的全新副本,则 xcopy 版本 是最小的,包含“即时客户端”并指向 DllPath到这个新位置。 但任何 Oracle 客户端安装都可以工作。
但是,如果您想避免所有这些非托管客户端解析问题,请查看是否可以更新您的应用程序以使用 100% 托管提供程序 - 它实际上只是一两个托管程序集,而不依赖于非托管文件。
如果 Oracle.DataAccess.dll 安装在您的 bin 目录和 GAC 中,您也可能没有加载您认为的 Oracle.DataAccess.dll,但我认为这种情况不太可能发生。 请参阅 程序集解析过程了解更多信息。
TLDR Version:
Full version:
First, lets make sure we understand the components of the old unmnaged provider (not the new 12c 100% managed provider). It's made up of two pieces:
Simply speaking, Oracle.DataAccess.dll is nearly just a wrapper, translating .net instructions into ORACLE-NET instructions for the unmanaged client.
That said, when you load Oracle.DataAccess there is a order in which it tries to locate the unmanaged client dlls that it needs. From the Oracle Documentation:
So in your case, your app followed this process above and found a path that has unmananged dlls that are too old relative to the Oracle.DataAccess.dll assembly that you are using.
It could just be that the only Oracle Client install on that machine is too old. But this comes into play if you have more than one client installed on the machine and the unmananaged files were found first in a different but older installation. If the later, the simple thing to do is use the dllPath configuration variable in your config and point it at the correct Oracle Home Bin folder:
If you want to install a fresh copy of the client, the xcopy version is the smallest and contains the "instant client" and point the DllPath above to this new location. But any oracle client install will work.
But if you want to avoid all this unmanaged client resolution stuff, see if you can update your app to use the 100% managed provider instead - it truely is just one or two managed assemblies,without any dependency on unmananged files.
Its also possible that you aren't loading the Oracle.DataAccess.dll that you think you are if it is installed in both your bin directory and your GAC, but I think that is the less likely senario. See the assembly resolution process for more information.
IIS/IWAM用户是否有Oracle目录的权限? 您可以使用其他应用程序(例如 Excel 或 Access)连接到此数据源吗?
Does the IIS/IWAM user have permissions on the Oracle directory? Can you connect to this data source using another app, such as Excel or Access?
我有同样的问题。 编译应用程序后,我删除了(并且忘记了我已经删除了)oraociei11.dll。 并且在尝试执行时出现此错误。 因此,当它找不到 oraociei11.dll 的 dll 时,它会显示此错误。 可能还有其他情况会出现此错误,但这似乎是其中之一。
I had the exact same problem. I deleted (and forgot that I had deleted) oraociei11.dll after compiling the application. And it was giving this error while trying to execute. So when it cant find the dll that oraociei11.dll, it shows this error. There may be other cases when it gives this error, but this seems to be one of them.
还要查找 IIS 应用程序池启用 32 位 true 或 false 标志,当您看到此消息时,一些 Oracle 论坛指示我这样做!
Also look for IIS Application pool Enable 32-bit true or false flag, when you see this message, some oracle forum directed me for this!
对于仍然遇到此问题的任何人:根据这篇文章
http://oradim.blogspot.com/2009/09/odpnet-provider-is-not-company-with.html
我发现我的服务器缺少 Microsoft C++ Visual Runtime Library - 我已经安装了它我的开发机器因为安装了 Visual Studio。 我从这里下载并安装了该库的(当前)最新版本:
http://www.microsoft.com/en-us/download/details.aspx?id=13523
运行设置,C# 的 oracle 调用成功了!
For anyone still having this problem: based on this article
http://oradim.blogspot.com/2009/09/odpnet-provider-is-not-compatible-with.html
I found out that my server was missing the Microsoft C++ Visual Runtime Library - I had it on my dev machine because of the Visual Studio installed. I downloaded and installed the (currently) most recent version of the library from here:
http://www.microsoft.com/en-us/download/details.aspx?id=13523
Ran the setup and the oracle call from C# made it!
我没有走上获取新 DLL 的道路。 我们有很多现有的项目运行得很好,只有我的新项目让我头疼,所以我决定尝试其他东西。
我的项目使用的是内部开发的Internal.dll,它依赖于Oracle.DataAccess.dll
v4.112.3.0
。 由于某种原因,发布时,Visual Studio 始终上传v4.121.0.0
,即使没有在任何配置文件中明确指定。 这就是我收到错误的原因。所以我所做的是:
/bin
(只是为了安全起见)。/bin
。myWebSite.csproj
中,但显示了错误的版本:v4.121.0.0
而不是v4.112.3.0
代码>.我手动更改了
myWebSite.csproj
中的引用,因此现在显示为:I didn't go down the road of getting new DLL's. We had a bunch of existing projects that work perfectly fine and it was only my new project that was giving me headache so I decided to try something else.
My project was using an internally developed Internal.dll that depended on Oracle.DataAccess.dll
v4.112.3.0
. For some reason, when publishing, Visual Studio always uploadedv4.121.0.0
, even though it wasn't explicitly specified in any of the config files. That's why I was getting an error.So what I did was:
/bin
(just to be on the safe side)./bin
.myWebSite.csproj
, but it showed the wrong version:v4.121.0.0
instead ofv4.112.3.0
.I manually changed the reference in
myWebSite.csproj
, so it now read:如果您有多个 Oracle 客户端,或者有时引用不同版本,则在使用非托管 Oracle 引用时可能会发生此问题
有两种方法可以解决这个问题:
第一个也是快速的解决方案是删除非托管引用并使用 NuGet 中的托管引用,请在使用此选项之前查看此内容 ODP.NET 托管驱动程序和非托管驱动程序之间的差异
第二个解决方案是修复项目非托管目标版本,如下所示:
然后检查 oracle GAC 版本
从 run (Win+R) "%windir%\Microsoft.NET\ assembly 获取 gac ”
检查与您的项目平台匹配的平台
检查您的目标平台(右键单击您的项目>属性)
从 gac 文件夹搜索到 Oracle.DataAccess
右键单击 Oracle.DataAccess > 属性> 详细信息并检查版本
如果您发现版本不同,这是一个问题,要解决它,我们需要重定向程序集版本(在启动项目中转到配置文件并添加以下部分)
如下所示
oldVersion :应该覆盖你的项目版本
新版本:广汽版本
publicKeyToken :来自 GAC
This issue could by happen while using unmanaged oracle reference if you have more than one oracle client , or sometimes if you reference different version
There is two way to solve it :
First and fast solution is to remove unmanaged reference and use the managed one from NuGet see this before to go with this option Differences between the ODP.NET Managed Driver and Unmanaged Driver
Second solution is to fix project unmanaged target version like the below :
Then check oracle GAC version
got to gac from run (Win+R) "%windir%\Microsoft.NET\assembly"
Check the platform that matches with you project platform
to check you target platform (right click on your project > properties)
From gac folder search to Oracle.DataAccess
Right Click on Oracle.DataAccess > properties > details and check version
if you notice the versions are different this is an the issue and to fix it we need to redirect assembly version (in startup project go to config file and add the below section )
like this
oldVersion : should be cover your project version
newVersion : GAC version
publicKeyToken : From GAC
我们遇到了同样的问题,因为网络共享上的 Oracle.Data.dll 程序集已由我们的 DBA 更新。 从项目中删除引用,然后再次添加即可解决问题。
We had the same problem, because the Oracle.Data.dll assembly on a network share was updated by our DBA's. Removing the reference from the project, and adding it again solved the problem.
只需两步即可解决此问题。
祝你好运。
Just two steps to solve this issue.
best of luck.
最近,我必须处理一个较旧的项目,其中解决方案和所有包含的项目都针对 x32 平台。 我一直尝试在所有位置复制 Oracle.DataAccess.dll 和所有其他建议的 Oracle 文件,但每次都碰壁。 最后,头部的灯泡亮了(8 小时后:)),并要求检查已安装的 ODAC 组件及其平台。 我已经安装了所有 64 位 (x64) ODAC 客户端,但没有安装 32 位 (x32)。 安装32位ODAC后问题就消失了。
如何检查已安装的 ODAC 的版本:查看文件夹 C:\Windows\Assembly。 “处理器架构”属性将告知平台已安装的 ODAC。
八小时对于灯泡点亮来说是很长的时间。 难怪我总是要努力工作:)。
Recently I had to work on an older project where the solution and all contained projects were targeted to x32 platform. I kept on trying to copy Oracle.DataAccess.dll and all other suggested Oracle files on all the places, but hit the wall every time. Finally the bulb in the head lit up (after 8 hours :)), and asked to check for the installed ODAC assemblies and their platform. I had all the 64-bit (x64) ODAC clients installed already but not the 32 bit ones (x32). Installed the 32-bit ODAC and the problem disappeared.
How to check the version of installed ODAC: Look in folder C:\Windows\assembly. The "Processor Architecture" property will inform the platform of installed ODAC.
Eight hours is a long time for the bulb to light up. No wonder I always have to slog at work :).
我在安装Oracle Data Tools for Visual Studio 2015后遇到了这个问题,然后与Oracle战斗了好一个小时。 我决定再次尝试重新安装 Oracle 客户端,而不是像文件复制、配置更改等那样混乱,这对我有用。
I encountered this problem after I installed Oracle Data Tools for Visual Studio 2015, and then fighting with Oracle for a good hour. I decided to try reinstalling Oracle client again instead of this mess with file copying, config changes, etc., and that worked for me.
我遇到了类似的问题,根本原因是 GAC 有 2 个 oracle.dataaccess 版本,即 v4.0_4.112.2.0 和 v4.0_4.112.4.0 。 我的应用程序引用了 v4.0_4.112.2.0 ,因此当我从 GAC 中删除 v4.0_4.112.4.0 时,它工作正常。
GAC 路径:C:\Windows\Microsoft.NET\ assembly\GAC_64\Oracle.DataAccess
之前:
之后:
要删除版本,只需从 GAC 中删除相应的文件夹即可。
I faced a similar issue and the root cause was that GAC had 2 oracle.dataaccess versions i.e. v4.0_4.112.2.0 and v4.0_4.112.4.0 . My application was referring to v4.0_4.112.2.0 , so when I removed v4.0_4.112.4.0 from GAC, it worked fine.
GAC path : C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess
Before :
After :
To remove a version, one can simply delete the corresponding folder from GAC.
因此,对于仍在与这个恶魔作斗争的任何人,请记住两件事:
这两个取决于您的应用程序和 Oracle.DataAccess .dll 版本。
我不断收到此错误,因为我没有安装正确的 Oracle 数据库客户端版本。 当我需要 11g 时,我只安装了 19c。 您可以毫无问题地安装多个版本。
安装 32 位 11g Oracle 数据库客户端后,我终于成功了。 您可能会在 Oracle 软件交付云中找到旧版本的 Oracle 数据库客户端,只要仔细查找,它们就在那里。
So, for anyone still battling this demon, keep 2 things in mind:
These 2 depend on your application and Oracle.DataAccess .dll version.
I kept getting this error because I didn't have the correct Oracle Database Client version installed. I only had the 19c installed when I needed the 11g. You can have multiple versions installed with no problem whatsoever.
After installing the 32bit 11g Oracle Database Client, that finally did the trick for me. You may find older versions of the Oracle Database Client in Oracle's Software Delivery Cloud, just look for them carefully, they're there.
您的应用程序的 bin 目录。
您的应用程序的 bin 目录。
http://randomdevtips.blogspot.com/2012 /06/provider-is-not-compat-with-version.html
the bin directory for your application.
the bin directory for your application.
http://randomdevtips.blogspot.com/2012/06/provider-is-not-compatible-with-version.html
克里斯的解决方案也对我有用。 然而,我确实收到了一条错误消息,其中指出:
显然,在 Oraclish 的外语中,这意味着您的程序要么针对所有平台,要么针对 32 位机器。
只需将“项目属性”中的目标平台更改为 64 位即可,祝一切顺利。
Chris' solution worked for me as well. I did however get a follow error message that states:
Apparently, in the foreign language of Oraclish, that means that your program are either targeting all platforms, or 32-bit machines.
Simply change your target platform in Project Properties to 64-bit and hope for the best.
我对 Oracle.DataAccess.dll v4.121.2.0 也有同样的问题。 2 个家庭安装(32 和 64 位版本)。 32位版本有workerd,64位版本没有。
就我而言(经过 2 天的尝试),我发现问题在于 64 位家庭版本的权限。 该版本中的许多目录具有独占覆盖权限,其中“经过身份验证的用户”角色没有“读取”访问权限,这是默认在父目录上设置的。 这些子目录包括“bin”、“network/admin”、“nls”、“oracore”、“RDBMS”以及可能的其他子目录。 我通过从 sysinternals 中过滤掉“进程监视器”(Procmon.exe) 实用程序中的“访问被拒绝”结果来找到它们。 一旦权限从父目录继承到这些子子目录,一切就开始工作了。
我没有覆盖整个 oracle 主目录的权限,所以我一次只执行一个目录,但我想如果您不太担心安全性,您可以在整个相应的 oracle 主目录上重置它。
I had the same issue with Oracle.DataAccess.dll v4.121.2.0. with 2- homes installation (32 and 64 bit versions). 32-bit version workerd, 64-bit version didn't.
In my case (after 2 days of trying) I found that the problem was permissions on the 64-bit-home version. Many Directories in that version had exclusively overridden permissions where "Authenticated Users" role did not have "Read" access, which is set by default on the parent directory. Those sub-directories included "bin", "network/admin", "nls", "oracore", "RDBMS" and possibly others. I found them by filtering out "ACCESS DENIED" result in "Process Monitor" (Procmon.exe) utility from sysinternals. Once the permissions were inherited from the parent directory to those child subdirectories everything started to work.
I didn't what to override the permissions on the whole oracle home so I did them one directory at a time, but I guess if you don't worry about security so much you can reset it on the whole corresponding oracle home directory.
这里有很多理论答案,但这里有一个工作示例,其中包含可以立即复制、粘贴和测试的代码:
这些 DLL 必须与 EXE 位于同一目录中,或者您必须在以下位置指定 DLL 路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.112.4.0\DllPath
。 在 64 位计算机上,另外写入HKLM\SOFTWARE\Wow6432Node\Oracle\...
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.121.2.0\DllPath
Oracle.ManagedDataAccess.dll
,它只有 4 MB,是一个纯托管 DLL,也可以在 32 位和 64 位进程中工作,并且依赖于没有其他 DLL,也不需要任何注册表项。Lots of theoretical answers here, but here comes a working example with code that you can copy and paste and test immediately:
These DLLs must be in the same directory as the EXE or you must specify the DLL path in:
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.112.4.0\DllPath
. On 64 bit machines write additionally toHKLM\SOFTWARE\Wow6432Node\Oracle\...
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.121.2.0\DllPath
Oracle.ManagedDataAccess.dll
which is only 4 MB and is a pure managed DLL which works in 32 bit and 64 bit processes as well and depends on no other DLL and does not require any registry entries.