我希望我的应用程序使用Oracle 11g ODAC,但似乎是使用12c的那些....我如何强制我的应用程序使用11g ODAC?
出于某种原因,我在我的PC(Windows 7 Pro SP1 64位)中跟随客户端和ODT:
- Oracle 11g Client (64-bit) version 11.2.0.3.0 - Oracle 12c Client (64-bit) version 12.1.0.1.0 - Oracle 12c ODT (Oracle Developer Tools for Visual Studio) (32-bit)而且,我的.net项目(visual studio 2013)引用了“Oracle.DataAccess.dll”,它存储在:C:\ Windows \ Microsoft.NET \ assembly \ GAC_64 \ Oracle.DataAccess \ v4.0_4.112.3.0__89b483f429c47342
我的环境路径的顺序是这样的:
C:\oracle12c\product\12.1.0\client_2; C:\oracle12c\product\12.1.0\client_2\bin; C:\oracle12c\product\12.1.0\client_1; C:\oracle12c\product\12.1.0\client_1\bin; C:\Oracle\product\11.2.0\client_1; C:\Oracle\product\11.2.0\client_1\bin;我试过的是在web.config文件中指定dllPath,如下所示:
<oracle.dataaccess.client> <settings> <add name="DllPath" value="C:\Oracle\product\11.2.0\client_1\bin"/> </settings> </oracle.dataaccess.client>但是,它不起作用。 当调用OracleConnection类的构造函数时,我收到以下错误:
System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize() at Oracle.DataAccess.Client.OracleConnection..cctor() --- End of inner exception stack trace ---任何信息都会有所帮助。 先谢谢你!
--- Yukapod于10月14日更新---
我发现我的应用程序不需要12c ODT 32位版本,因此我将其从我的PC中删除并再次尝试。 但情况并没有改变; 在调用OracleConnection类的构造函数之后,我仍然得到“提供程序与Oracle客户端版本不兼容”错误。 我想知道问题出在哪里....
我的web.config中仍然有以下配置:
<oracle.dataaccess.client> <settings> <add name="DllPath" value="C:\Oracle\product\11.2.0\client_1\bin"/> </settings> </oracle.dataaccess.client>而且,这是我当前的环境PATH变量:
C:\oracle12c\product\12.1.0\client_1; C:\oracle12c\product\12.1.0\client_1\bin; C:\Oracle\product\11.2.0\client_1; C:\Oracle\product\11.2.0\client_1\bin;哪里
C:\oracle12c\product\12.1.0\client_1 -> ORACLE_HOME for Oracle 12c Client (64-bit) version 12.1.0.1.0 Oracle\product\11.2.0\client_1 -> ORACLE HOME for Oracle 11g Client (64-bit) version 11.2.0.3.0甚至我颠倒了PATH变量的顺序(我的意思是,让11g先来),结果没有改变(仍然有相同的错误)。 如果有人知道某事,任何类型的信息都将非常有用。 再次感谢您!
I want my application to use Oracle 11g ODAC, but it seems to be using those for 12c.... How can I force my application to use the 11g ODAC?
For some reason, I have following clients and ODT in my PC (Windows 7 Pro SP1 64-bit):
- Oracle 11g Client (64-bit) version 11.2.0.3.0 - Oracle 12c Client (64-bit) version 12.1.0.1.0 - Oracle 12c ODT (Oracle Developer Tools for Visual Studio) (32-bit)And, my .net project (visual studio 2013) referes "Oracle.DataAccess.dll" which is stored in: C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342
The order of my environment path is like this:
C:\oracle12c\product\12.1.0\client_2; C:\oracle12c\product\12.1.0\client_2\bin; C:\oracle12c\product\12.1.0\client_1; C:\oracle12c\product\12.1.0\client_1\bin; C:\Oracle\product\11.2.0\client_1; C:\Oracle\product\11.2.0\client_1\bin;What I have tried is to specify dllPath in the web.config file like this:
<oracle.dataaccess.client> <settings> <add name="DllPath" value="C:\Oracle\product\11.2.0\client_1\bin"/> </settings> </oracle.dataaccess.client>However, it does not work. When the constructor of OracleConnection class is called, I get the following error:
System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize() at Oracle.DataAccess.Client.OracleConnection..cctor() --- End of inner exception stack trace ---Any information will be helpful. Thank you in advance!
--- UPDATE Oct 14 by Yukapod ---
I've found that my application does not require 12c ODT 32-bit version, so I removed it from my PC and tried again. However, the situation has not changed; I still get the "The provider is not compatible with the version of Oracle client" error just after the constructor of OracleConnection class is called. I'm wondering where the problem is....
I still have the following configuration in my web.config:
<oracle.dataaccess.client> <settings> <add name="DllPath" value="C:\Oracle\product\11.2.0\client_1\bin"/> </settings> </oracle.dataaccess.client>And, this is my current environment PATH variable:
C:\oracle12c\product\12.1.0\client_1; C:\oracle12c\product\12.1.0\client_1\bin; C:\Oracle\product\11.2.0\client_1; C:\Oracle\product\11.2.0\client_1\bin;where
C:\oracle12c\product\12.1.0\client_1 -> ORACLE_HOME for Oracle 12c Client (64-bit) version 12.1.0.1.0 Oracle\product\11.2.0\client_1 -> ORACLE HOME for Oracle 11g Client (64-bit) version 11.2.0.3.0And even I reversed the order of the PATH variable (I mean, make 11g come first), the result did not change (still have the same error). If anyone knows something, any kind of information will be very helpful. Thank you in advance again!
最满意答案
谢谢大家帮帮我! 我终于找到了这个问题的原因。
原因:
12c的Policy DLL将11g的所有引用重定向到12c。
细节:
我首先安装了11g客户端,然后安装了12c客户端,因此我的GAC中有两个策略文件夹(C:\ Windows \ Microsoft.NET \ assembly \ GAC_64 \ Policy.4.112.Oracle.DataAccess):
v4.0_4.112.3.0__89b483f429c47342 <== policy folder for 11g v4.0_4.121.1.0__89b483f429c47342 <== policy folder for 12c在每个文件夹中,您都可以看到Policy。[version] .Oracle.DataAccess.config文件。
11g的配置文件是这样的:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/> <bindingRedirect oldVersion="4.112.0.0-4.112.3.0" newVersion="4.112.3.0"/> <== This is OK! </dependentAssembly> </assemblyBinding> </runtime> </configuration>这是12c的那个:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/> <bindingRedirect oldVersion="4.112.0.0-4.112.9999.9999" newVersion="4.121.1.0"/> <== OMG!! The 11g version 4.0_4.112.3 is included! </dependentAssembly> </assemblyBinding> </runtime> </configuration>我不必关心环境PATH变量的顺序,或者我不必使用DllPath指定我想要的Oracle.DataAccess.dll版本。 就我而言,以下是使用特定ODAC的关键点:
- Make sure that my application has a reference for Oracle.DataAccess.dll for 11g. - Remove / rename the policy folder for 12c (v4.0_4.121.1.0__89b483f429c47342) in GAC.然后,我终于可以使用11g了。
Thank you all for helping me out! I finally found the cause of this problem.
Cause:
12c's Policy DLL is redirecting all the reference for 11g to 12c.
Details:
I installed 11g client first and then installed 12c clients, so there are two policy folders in my GAC (C:\Windows\Microsoft.NET\assembly\GAC_64\Policy.4.112.Oracle.DataAccess):
v4.0_4.112.3.0__89b483f429c47342 <== policy folder for 11g v4.0_4.121.1.0__89b483f429c47342 <== policy folder for 12cIn each folder you can see the Policy.[version].Oracle.DataAccess.config file.
The config file for 11g is like this:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/> <bindingRedirect oldVersion="4.112.0.0-4.112.3.0" newVersion="4.112.3.0"/> <== This is OK! </dependentAssembly> </assemblyBinding> </runtime> </configuration>And this is the one for 12c:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/> <bindingRedirect oldVersion="4.112.0.0-4.112.9999.9999" newVersion="4.121.1.0"/> <== OMG!! The 11g version 4.0_4.112.3 is included! </dependentAssembly> </assemblyBinding> </runtime> </configuration>I don't have to care for the order of the environment PATH variable, or I don't have to specify which version of Oracle.DataAccess.dll I want using DllPath. In my case, the followings are key points to use the specific ODAC:
- Make sure that my application has a reference for Oracle.DataAccess.dll for 11g. - Remove / rename the policy folder for 12c (v4.0_4.121.1.0__89b483f429c47342) in GAC.And then, I could finally use 11g.
更多推荐
发布评论