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 pag
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.
You have no Oracle Client installed. In this case the error message is indeed misleading.
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 on oraociei*.dll
and/or OraOps*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.
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:
False
False
Attributes like Version=...
or processorArchitecture=...
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 link ora112
to folder C:\Oracle\11.2\Client_x64
(see below)
Change to folder %WINDIR%\SysWOW64, typically C:\Windows\SysWOW64
and create a symbolic link ora112
to folder C:\Oracle\11.2\Client_x86
, (see below)
Modify the PATH
environment variable, replace all entries like C:\Oracle\11.2\Client_x86
and C:\Oracle\11.2\Client_x64
by C:\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 to C:\Windows\System32\ora112
Open your Registry Editor. Set Registry value HKLM\Software\ORACLE\KEY_OraClient11g_home1\ORACLE_HOME
to C:\Windows\System32\ora112
Set Registry value HKLM\Software\Wow6432Node\ORACLE\KEY_OraClient11g_home1\ORACLE_HOME
to C:\Windows\System32\ora112
(not C:\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:
cd C:\Windows\System32
mklink /d ora112 C:\Oracle\11.2\Client_x64
cd C:\Windows\SysWOW64
mklink /d ora112 C:\Oracle\11.2\Client_x86
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, whereas C:\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 example TNS_ADMIN=C:\Oracle\Common\network
.