Wednesday, March 21, 2012

FileNotFoundException: Could not load file orassembly 'Oracle.DataAccess'

Wednesday, March 21, 2012 Posted by Andre Broers , ,
When running Oracle Applications on other machines as development, we run into problems with different versions of oracle client installations. This will result in the following error:
FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies

One solution is to look in the c:\windows\assemblies folder to look what version of odp.net oracle assemblies are installed. Now you can create a redirect in the app.config or web.config by adding the following piece of code after the <configSections> :

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
      <bindingRedirect oldVersion="4.102.000.000-4.112.999.999" newVersion="2.111.7.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

In line 5 you can give the oldVersion (or a range of versions) and the newVersion (which is the version installed in the Global Assembly Cache (c:\windows\assemblies))
You can add more redirects for other assemblies if you want.