Oracle.Dataaccess is in the GAC. Can I use the version that I am using?

I have an XCOPY application for deploying .NET using Oracle.DataAccess (ODP.NET). We also deploy the Oracle Instant client in the application directory. Everything is working fine, but I'm worried ..

From the Oracle ODP.NET FAQs:

Starting with ODP.NET 10.1.0.3, the Oracle installer will register the following publisher DLLs in the global assembly cache (GAC) to redirect 9.2, 10.1, and 10.2 of the ODP.NET application to use the latest installed version of ODP.NET: Policy.9.2.Oracle. DataAccess.dll and Policy.10.1.Oracle.DataAccess.dll

This means that on computers where Oracle ODP.NET is installed, the version in the GAC will be used, and not the one that I deploy with my application. And because of the publisher’s policy, this version may be new than the one I deploy with my application. Oracle.DataAccess requires that the Oracle client (Instant) also be deployed with my application. These are native Win32 libraries, so my version will be used.

Is it possible that Oracle can upgrade Oracle.DataAccess to a newer version that may not be compatible with the Oracle Instant Client deployed with my application? And thus, a violation of my application in the future.

This is problem? And can I avoid this? Without installing / uninstalling anything on the machine, can I override the Oracle Publishers policy to ensure that I am using the version of Oracle.Dataaccess that I am deploying xcopy with my application?

For this version of ODP.NET, which versions of Oracle Clients support it? Will new versions of Oracle.DataAccess support older versions of Oracle (Instant) Client.

+4
source share
4 answers

You can force the application to always use the correct version of ODP and ODAC.

  • Force ODP Version: Use the assemblyBinding trick published by Robert to use the Oracle.DataAccess version instead of the GAC'd version. For instance:.

    <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> 
  • Force ODAC version: ODP DLL depends on a set of common Oracle components (instant client, unmanaged OCI DLI libraries). One way to get them is through the ODAC package. You can determine (for each application) which ODAC package you want to use. Traditionally, this was done using the PATH env variable, but now it can 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> 
  • As an added precaution, you can always remove the GAC'd publisher policy DLL to ensure that no funk happens.

+3
source

You can use assemblyBinding in the app.config file.

Here are some links that show how to use them.

http://blogs.msdn.com/b/suzcook/archive/2004/05/14/132022.aspx http://stackoverflow.com/questions/1165190/is-there-a-way-to-force-using -a-dll-version

+1
source

I combined Robert and Arv with my previous efforts:

  • Set SpecificVersion to True in the properties of the Oracle.DataAccess project and make sure that the specified version matches 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 will automatically find the version number in the GAC. If the version does not already exist in the GAC, you must first install ODAC.

    <Reference Include = "Oracle.DataAccess, Version = 2.111.7.20, Culture = neutral, PublicKeyToken = 89b483f429c47342, processorArchitecture = x86" />

  • Make sure that the first OraOps11w.dll file found in the path is the version you want to use. If not, change the Windows system path so that the Oracle Client directory that you want to use is the first path entry.

C: \ app \ user \ product \ 11.1.0 \ client_1; C: \ app \ user \ product \ 11.1.0 \ client_1 \ bin; another way

  • Disable publisher policy in Web.config or App.config
   <configuration>
 ...
      <runtime>
         <assemblyBinding xmlns = "urn: schemas-microsoft-com: asm.v1">
 ...
             <dependentAssembly>
             <assemblyIdentity name = "Oracle.DataAccess"
                                     publicKeyToken = "89b483f429c47342"
                                     culture = "neutral" />
             <publisherPolicy apply = "no" />
             </dependentAssembly>
         </assemblyBinding>
      </runtime>
   </configuration>

It might be better to close Visual Studio when editing csproj / web.config files in Notepad ++ or in your favorite text editor. But usually, Visual Studio asks if you want to reload the project or not.

+1
source

To force Oracle 11 and 12 to play together, I had to make the following changes to the app.config file. This is the only change I made, I did not make any changes to the project file, for example, changing the specific version from false to true.

 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup> <!--Add This Section to run Oracle 11 and !2 side By Side --> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" culture="neutral" publicKeyToken="89b483f429c47342"/> <codeBase version="4.112.4.0" href="FILE://Oracle.DataAccess.dll"/> <publisherPolicy apply="no"/> </dependentAssembly> </assemblyBinding> <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"/> <publisherPolicy apply="no"/> </dependentAssembly> </assemblyBinding> </runtime> <!--Add the above Section to run Oracle 11 and 12 side By Side --> 

0
source

Source: https://habr.com/ru/post/1397569/


All Articles