Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 246
Arve Avatar asked Feb 21 '12 08:02

Arve


1 Answers

It's possible to force your application to always use the ODP and ODAC version you want.

  1. Force 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.:

    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Oracle.DataAccess"  culture="neutral" publicKeyToken="89b483f429c47342"/>
            <codeBase version="4.112.3.0" href="FILE://Oracle.DataAccess.dll"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    
  2. Force 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:

    <configuration>
      <configSections>
        <section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </configSections>
    
      <oracle.dataaccess.client>
        <settings>
          <add name="DllPath" value="C:\somefolder\ODAC_11.2.0.3.0_32bit\bin" />
        </settings>
      </oracle.dataaccess.client>
    </configuration>
    
  3. As an extra precaution, you can always delete the GAC'd publisher policy DLL, to ensure there is never any funky going on.

like image 130
Martin Suchanek Avatar answered Nov 15 '22 07:11

Martin Suchanek