Question

I'm doing asp.net mvc3, and I have a problem with ODP.NET, Oracle.DataAccess.

Whenever I try to do my unit test, it throws a FileNotFoundException. I thought I've installed and been using Oracle.DataAccess v4.112.3.0, but my application keeps looking for 'Oracle.DataAccess, Version=4.121.1.0'.

Still I can find 'Oracle.DataAccess v4.112.3.0' in my GAC and through the FusionLog I found belows in my machine.config. So I guess there are some version conflict of ODP.NET.

<system.data>
<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=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>

So, I've tried to modify the version in the machine.config but it didn't work.

Anyone can help me to fix this?

Was it helpful?

Solution

You can always force a specific version with a runtime redirect in web.config (or machine.config), provided the Oracle dll's interface across versions has stayed the same:

<runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
         <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/>
         <bindingRedirect oldVersion="4.121.1.0" newVersion="4.112.3.0"/>
      </dependentAssembly>
   </assemblyBinding>     
</runtime>

From my experience this trick has worked when redirecting from 10.1 to any newer version, but once we ran in mysterious errors when trying to redirect backward (see this), therefore I advise you to better find the exact reason why this is happening - look in your *.csproj which Oracle.DataAccess exactly is referenced and/or disassemble your binaries to inspect also the references of referenced libraries. (It is possible that rather than your code some 3rd party lib you use wants this exact version of ODP.NET).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top