简体   繁体   English

Oracle.Dataaccess在GAC中。我可以控制我使用的版本吗?

[英]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). 我有一个使用Oracle.DataAccess(ODP.NET)的XCOPY可部署.NET应用程序。 We also deploy the Oracle Instant client in the application directory. 我们还在应用程序目录中部署Oracle Instant Client。 Everything works OK, but I worry.. 一切正常,但我担心..

From the Oracle ODP.NET FAQ: 来自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 从ODP.NET 10.1.0.3开始,Oracle安装程序将在全局程序集缓存(GAC)中注册以下发布者策略DLL,该程序重定向9.2,10.1和10.2 ODP.NET应用程序以使用上次安装的ODP.NET版本:策略.9.2.Oracle.DataAccess.dll和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. 这意味着在安装了Oracle ODP.NET的计算机上,将使用GAC中的版本,而不是我在应用程序中部署的版本。 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. Oracle.DataAccess还需要与我的应用程序一起部署的Oracle(Instant)客户端。 These are native Win32 DLLs so my version will be used. 这些是本机Win32 DLL,因此我的版本将被使用。

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? Oracle是否有可能将Oracle.DataAccess升级到可能与我的应用程序部署的Oracle Instant Client不兼容的较新版本? 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? 如果不在机器上安装/删除任何内容,我可以覆盖Oracle Publishers策略,以保证我使用我的应用程序部署xcopy部署的Oracle.Dataaccess版本吗?

For a given version of ODP.NET, what Oracle Clients versions does it support? 对于给定版本的ODP.NET,它支持哪些Oracle客户端版本? Will new versions of Oracle.DataAccess support old versions of the Oracle (Instant) Client. 新版本的Oracle.DataAccess是否支持旧版本的Oracle(Instant)客户端。

It's possible to force your application to always use the ODP and ODAC version you want. 可以强制您的应用程序始终使用您想要的ODP和ODAC版本。

  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. 强制ODP版本:使用Robert发布​​的assemblyBinding技巧,强制使用您的Oracle.DataAccess版本而不是GAC版本。 Eg: 例如:

     <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). 强制ODAC版本:ODP DLL依赖于一组共享的Oracle组件(即时客户端,非托管OCI dll)。 One way to get these is via the ODAC package. 获得这些的一种方法是通过ODAC包。 You can define (on a per app basis), which ODAC package you want to use. 您可以定义(基于每个应用程序),您要使用的ODAC包。 Traditionally this was done via the PATH env variable, but it can now be defined via config: 传统上这是通过PATH env变量完成的,但现在可以通过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. 作为额外的预防措施,您始终可以删除GAC发布者策略DLL,以确保永远不会有任何时髦。

I combined Robert & Arve's answer with my previous efforts : 我将Robert&Arve的回答与之前的努力相结合:

  • Set SpecificVersion to True in the Project's Oracle.DataAccess properties, and make sure the Version stated matches with the version you want to use. 在Project的Oracle.DataAccess属性中将SpecificVersion设置为True,并确保Version声明与您要使用的版本匹配。 If not, manually edit the csproj file to change the version number and delete the copied dll in the bin folder. 如果没有,请手动编辑csproj文件以更改版本号并删除bin文件夹中复制的dll。 Visual Studio would automatically find the version number in the GAC. Visual Studio将自动在GAC中找到版本号。 If the version is not yet exist in the GAC, you should install ODAC first. 如果GAC中尚不存在该版本,则应首先安​​装ODAC。

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

  • Make sure the first OraOps11w.dll found in the Path is the version you want to use. 确保Path中找到的第一个OraOps11w.dll是您要使用的版本。 If not, change Windows' System Path so that the directory of the Oracle Client you want to use is the first path entry. 如果没有,请更改Windows的系统路径,以便您要使用的Oracle客户端的目录是第一个路径条目。

C:\\app\\user\\product\\11.1.0\\client_1;C:\\app\\user\\product\\11.1.0\\client_1\\bin; C:\\应用\\用户\\产品\\ 11.1.0 \\的Client_1; C:\\应用\\用户\\产品\\ 11.1.0 \\的Client_1 \\ BIN; other path 其他路径

  • Disable publisher policy apply in the Web.config or App.config file 禁用发布者策略应用于Web.config或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 while editing csproj / web.config files in Notepad++ or your favorite text editor. 在Notepad ++或您喜欢的文本编辑器中编辑csproj / web.config文件时关闭Visual Studio可能会更好。 But usually Visual Studio asks you whether you want to reload the project or not. 但通常Visual Studio会询问您是否要重新加载项目。

You can use assemblyBinding in the app.config file. 您可以在app.config文件中使用assemblyBinding。

Heres a couple of links that show how to use it. 下面是几个显示如何使用它的链接。

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 http://blogs.msdn.com/b/suzcook/archive/2004/05/14/132022.aspx http://stackoverflow.com/questions/1165190/is-there-a-way-to-force-using-using -a-DLL版本

To get Oracle 11 and 12 to play nicely together I had to make the following changes to my app.config file. 为了让Oracle 11和12能够很好地协同工作,我必须对app.config文件进行以下更改。 This is the only change I made, I did not make any changes to my project file such as changing the specific version from false to true. 这是我做的唯一更改,我没有对我的项目文件进行任何更改,例如将特定版本从false更改为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  -->

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM