Hi,
I've installed OCI and ODP.Net from the Oracle 11.2.0.3 32 Bit client. The application I use runs on .net 4 but is built against Oracle.DataAccess.dll 2.112.1.0 32 Bit.
After install I have Oracle.DataAccess.dll in the .Net GAC C:\windows\assembly and an entry in the .net 2 32 bit machine config in dbproviderfactoris as follows
| <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> |
I also have Oracle.DataAccess.dll 4.112.3.0 32 Bit in the .Net 4 GAC C:\Windows\Microsoft.NET\assembly\GAC_32 and an entry in the .net 4 32 bit machine config with an entry in dbproviderfactories as follows
| <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> |
My application is a website (running 32 Bit under .net 4) which contains in it's bin folder the dll Oracle.DataAccess.dll 2.112.1.0 32 Bit.
When I started my application first I got an error
[A]Oracle.DataAccess.Client.OracleParameter cannot be cast to [B]Oracle.DataAccess.Client.OracleParameter. Type A originates from 'Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342\Oracle.DataAccess.dll'. Type B originates from 'Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' in the context 'Default' at location 'C:\Windows\assembly\GAC_32\Oracle.DataAccess\2.112.3.0__89b483f429c47342\Oracle.DataAccess.dll'.
My assumption was that it picks up the .Net 4 Data Provider factory so I added the following to my root web config
<system.data>
<remove invariant="Oracle.DataAccess.Client" />
<DbProviderFactories>
<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</DbProviderFactories>
</system.data>
However this brought me to the following message
Unable to find the requested .Net Framework Data Provider. It may not be installed.
I then re-registered the .Net 2 Odp.net dll in the GAC and afterwards in the machine confiig
GAC
C:\app\Administrator\product\11.2.0\client_1\odp.net\bin\2.x> oraprovcfg /action:gac /providerpath: C:\app\Administrator\product\11.2.0\client_1\odp.net\bin\2.x\Oracle.DataAccess.dll
Machine Config
C:\app\Administrator\product\11.2.0\client_1\odp.net\bin\2.x> oraprovcfg /action:config /product:odp /frameworkversion:v2.0.50727 /providerpath:"C:\app\Administrator\product\11.2.0\client_1\odp.net\bin\2.x\Oracle.DataAccess.dll"
I also tried removing the .Net 4 provider via oraprovcfg but this also didn't change anything in terms of behaviour.
In the end the only solution I could find was to change the .Net 4 machine config provider entry from
| <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/> |
to
| <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/> |
After this it works as expected.
However this isn't a very clean solution in my opinion so I would like to know if there is another way to resolve this. For me it seems both are registered correctly but only the .Net 4 provider is recognised for some reason.
I have one other small question as I have another client using 2.11.2.0 with and xcopy deployment and with this version I could not run the application without replacing the oracle.dataaccess.dll under the application. Strangely with 2.112.3.0 this isn't needed and it seems to work fine with 2.112.1.0,. Is that the expected behaviour?
Kind Regards,
Denis