Sunday, December 23, 2012

How to Make ODP.NET 4.0 (64 bit) working on 64 bit machine


When you Install ODP.NET 64 bit and try to use it in Visual Studio 2010 and the project is of type ASP.NET Website. it give the error from the web.config file during compile time.


"Could not load file or assembly 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified"

The best possibility to handle this is to use the x86 version locally with Visual Studio and x64 version on the server with IIS. To do this you have to download both versions - copy one in folder lib\x86 and the other in lib\x64 After this you have to modify the project file(s) - visual studio supports conditional references. Add following section to your project file:


 <PropertyGroup>
     <ReferencesPath Condition=" '$(Platform)' == 'x86' ">..\Lib\x86</ReferencesPath>   
     <ReferencesPath Condition=" '$(Platform)' == 'x64' ">..\Lib\x64</ReferencesPath>     
 </PropertyGroup>


After this reference the odp.net assmebly like this:


  <Reference ... processorArchitecture=$(Platform)">
   <SpecificVersion>False</SpecificVersion>
   <HintPath>$(ReferencesPath)\Oracle.DataAccess.dll</HintPath>          
   <Private>True</Private>
  </Reference>