Oracle.Dataaccess is in the GAC. Can I control the version I use?
NickName:Arve Ask DateTime:2012-02-21T16:30:09

Oracle.Dataaccess is in the GAC. Can I control the version I use?

I have a XCOPY deployable .NET application using Oracle.DataAccess (ODP.NET). We also deploy the Oracle Instant client in the application directory. Everything works OK, but I worry..

From the Oracle ODP.NET FAQ:

Beginning with ODP.NET 10.1.0.3, the Oracle installer will register the following publisher policy DLLs in the Global Assembly Cache (GAC) that redirect 9.2, 10.1 and 10.2 ODP.NET applications to use the last installed version of ODP.NET: Policy.9.2.Oracle.DataAccess.dll and Policy.10.1.Oracle.DataAccess.dll

This means that on machines where the Oracle ODP.NET is installed, the version in the GAC will be used, not the one I deploy with my application. And because of the publisher policy, that version may be newer than the one I deploy with my application. Oracle.DataAccess needs the Oracle (Instant) client also deployed with my application. These are native Win32 DLLs so my version will be used.

Is is possible that Oracle may upgrade the Oracle.DataAccess to a newer version that may not be compatible with the Oracle Instant Client deployed with my application? And thus breaking my application in the future.

Is this a problem? And can I avoid it? Without installing/removing anything on the machine can I override the Oracle Publishers policy to guarantee that I user the Oracle.Dataaccess version that I xcopy deploy with my application?

For a given version of ODP.NET, what Oracle Clients versions does it support? Will new versions of Oracle.DataAccess support old versions of the Oracle (Instant) Client.

Copyright Notice:Content Author:「Arve」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/9374323/oracle-dataaccess-is-in-the-gac-can-i-control-the-version-i-use

Answers
Robert 2012-02-21T08:56:33

You can use assemblyBinding in the app.config file.\n\nHeres a couple of links that show how to use it.\n\nhttp://blogs.msdn.com/b/suzcook/archive/2004/05/14/132022.aspx\nhttp://stackoverflow.com/questions/1165190/is-there-a-way-to-force-using-a-dll-version",


YudhiWidyatama 2014-02-25T04:28:55

I combined Robert & Arve's answer with my previous efforts :\n\n\nSet SpecificVersion to True in the Project's Oracle.DataAccess properties, and make sure the Version stated matches with the version you want to use. If not, manually edit the csproj file to change the version number and delete the copied dll in the bin folder. Visual Studio would automatically find the version number in the GAC. If the version is not yet exist in the GAC, you should install ODAC first.\n\n<Reference Include=\"Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86\" />\nMake sure the first OraOps11w.dll found in the Path is the version you want to use. If not, change Windows' System Path so that the directory of the Oracle Client you want to use is the first path entry.\n\n\n\n C:\\app\\user\\product\\11.1.0\\client_1;C:\\app\\user\\product\\11.1.0\\client_1\\bin;other path\n\n\n\nDisable publisher policy apply in the Web.config or App.config file\n\n\n\n\n <configuration>\n...\n <runtime>\n <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">\n...\n <dependentAssembly>\n <assemblyIdentity name="Oracle.DataAccess"\n publicKeyToken="89b483f429c47342"\n culture="neutral" />\n <publisherPolicy apply="no"/>\n </dependentAssembly>\n </assemblyBinding>\n </runtime>\n </configuration>\n\n\n\nIt might be better to close Visual Studio while editing csproj / web.config files in Notepad++ or your favorite text editor. But usually Visual Studio asks you whether you want to reload the project or not.",


Martin Suchanek 2012-02-22T11:05:20

It's possible to force your application to always use the ODP and ODAC version you want.\n\n\nForce ODP version: use the assemblyBinding trick posted by Robert, to force using your version of Oracle.DataAccess instead of the GAC'd version. E.g.:\n\n<configuration>\n <runtime>\n <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n <dependentAssembly>\n <assemblyIdentity name=\"Oracle.DataAccess\" culture=\"neutral\" publicKeyToken=\"89b483f429c47342\"/>\n <codeBase version=\"4.112.3.0\" href=\"FILE://Oracle.DataAccess.dll\"/>\n </dependentAssembly>\n </assemblyBinding>\n </runtime>\n</configuration>\n\nForce ODAC version: The ODP DLL depends on a set of shared Oracle components (instant client, unmanaged OCI dlls). One way to get these is via the ODAC package. You can define (on a per app basis), which ODAC package you want to use. Traditionally this was done via the PATH env variable, but it can now be defined via config:\n\n<configuration>\n <configSections>\n <section name=\"oracle.dataaccess.client\" type=\"System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" />\n </configSections>\n\n <oracle.dataaccess.client>\n <settings>\n <add name=\"DllPath\" value=\"C:\\somefolder\\ODAC_11.2.0.3.0_32bit\\bin\" />\n </settings>\n </oracle.dataaccess.client>\n</configuration>\n\nAs an extra precaution, you can always delete the GAC'd publisher policy DLL, to ensure there is never any funky going on.\n",


More about “Oracle.Dataaccess is in the GAC. Can I control the version I use?” related questions

Oracle.Dataaccess is in the GAC. Can I control the version I use?

I have a XCOPY deployable .NET application using Oracle.DataAccess (ODP.NET). We also deploy the Oracle Instant client in the application directory. Everything works OK, but I worry.. From the Ora...

Show Detail

How can I specify the version of a reference to Oracle.DataAccess

I have installed 2 versions of ODAC (Oracle Data Access Client), so I can see there're two assemblies in the GAC. Now I am trying to use the old one which is 4.112.2.0, but no matter how I did, the

Show Detail

Oracle.DataAccess version could not load

I am having trouble with Oracle.DataAccess in WPF. I used Oracle.DataAccess v4.0 without any problems. But now it updated to version 4.112 and when I add reference to this version in WPF the designer

Show Detail

asp.net core Oracle.DataAccess System.BadImageFormatException: Could not load file or assembly Oracle.DataAccess

I've added Oracle.DataAccess as reference to asp.net core project. I've only installed Oracle Data Provider for .Net when installed ODAC. I would like to make a simple example with Dapper on the pr...

Show Detail

Dynamically choose Oracle.DataAccess version

Is there a way to build our web application to dynamically choose Oracle version? I think you can use binding redirect, but I am not sure if it requires the versions to be in the GAC (our assemblie...

Show Detail

Specific Version = False ignored for Oracle.DataAccess

My DB Utilities project has a reference to Oracle.DataAccess 2.112.3.0, which is set as Specific Version = False, however projects that reference this DB Utilities are requiring this exact version ...

Show Detail

Referencing the correct version of Oracle.DataAccess in .NET

I'm trying to reference Oracle.DataAccess from a .NET 4.0 project, written on Visual Studio 2013. My machine's GAC has two versions of Oracle.DataAccess installed: 4.112.1.2 (provided by Oracle ver...

Show Detail

OracleBulkCopy is missing in Oracle.DataAccess

I want to use OracleBulkCopy to perform some bulk insert operations. My database is Oracle10g and my code is in .NET 2 framework. It is for some old clients and i cannot upgrade database or framework

Show Detail

Oracle.DataAccess FileNotFoundException

I'm doing asp.net mvc3, and I have a problem with ODP.NET, Oracle.DataAccess. Whenever I try to do my unit test, it throws a FileNotFoundException. I thought I've installed and been using Oracle.

Show Detail

Getting error "add assembly="Oracle.DataAccess,Version=someversion, Culture=neutral, PublicKeyToken=somenumbers"/"

for example, can I have a label in my asp.net webpage, and it's text can be assigned to the version of the oracle dll when running the project? Is there a method so that I can know the version of the

Show Detail