title: How to tell System.Data.OracleClient to use the 64 bit Oracle Driver
body: <p>I am trying to run a .NET application which uses <code>System.Data.OracleClient</code> on a Win7 x64 workstation. The workstation has a 32bit Oracle client installed, which leads to the following error message:</p>
  
  <blockquote>
    <p>Attempt to load Oracle client libraries threw BadImageFormatException.  This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.</p>
  </blockquote>
  
  <p>So this is my long journey of tries and failures:</p>
  
  <ol>
  <li>I tried to install the Oracle client <strong><a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html" rel="nofollow noreferrer">win64_11gR2_client</a></strong>. But during the setup process it crashes without any comment.</li>
  <li>I followed an <a href="https://stackoverflow.com/questions/1461376/how-can-i-specify-the-oracle-home-to-use-when-using-system-data-oracleclient/1464255#1464255">answer from a different SO thread</a>, tried and extracted the <strong><a href="http://www.oracle.com/technetwork/topics/winx64soft-089540.html" rel="nofollow noreferrer">instantclient-basic-windows.x64-11.2.0.2.0</a></strong>, and put the folder containing the binaries in the windows PATH variable. I still get the same error message though (even after rebooting).</li>
  <li>I followed the "alternative way" from <a href="https://stackoverflow.com/questions/70602/what-is-the-minimum-client-footprint-required-to-connect-c-to-an-oracle-database/70901#70901">this answer</a> and copied the files <strong><em>oci.dll, orannzsbb11.dll,</em> and <em>oraociei11.dll</em></strong> into the bin/ folder of my web site project. Still the same error message.</li>
  <li>I tried and copied <strong><em>all</em> files from the instant client</strong> into that directory and tried again, without success.</li>
  <li>I installed <strong><a href="http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html" rel="nofollow noreferrer">ODAC112021Xcopy_x64.zip</a></strong> and put the installation folder and the bin folder in the windows PATH variable. No success.</li>
  <li>I put my hope on <a href="https://stackoverflow.com/questions/1461376/how-can-i-specify-the-oracle-home-to-use-when-using-system-data-oracleclient/1464129#1464129">this answer</a> and reviewed the <strong>DllPath</strong> in the registry (which is actually supposed to relate to ODP.NET as opposed to <code>System.Data.OracleClient</code>) and saw that DllPath points to the correct x64 installation of ODAC, so, if my application wasn't using <code>System.Data.OracleClient</code>, it should work,b but since it does use that, it still failed.</li>
  <li>I googled and stackoverflew but didn't find anything else that the posts I already referred to.</li>
  <li>I carefully crafted this SO question in the hope of getting any insightful advice from an enlightened SO user.</li>
  <li><p>After getting the first answer from b_levitt, I tried and added the following lines to the Global.asax at <code>Application_Start</code>:</p>
  
  <pre><code>Environment.SetEnvironmentVariable("ORACLE_HOME", @"C:\OracleProducts\Odac-11.2.0.2.1-x64");
  Environment.SetEnvironmentVariable("PATH", @"C:\OracleProducts\Odac-11.2.0.2.1-x64;C:\OracleProducts\Odac-11.2.0.2.1-x64\bin");
  </code></pre>
  
  <p>C:\OracleProducts\Odac-11.2.0.2.1-x64 is where I installed the ODAC 64 bit xcopy version. <strong>No success either.</strong></p></li>
  </ol>
  
  <p>On a related note, I even tried to <a href="https://stackoverflow.com/questions/6523075/how-to-force-net-application-to-run-in-32bit-mode">force my .NET app into 32bit mode without success</a>, but that's a different thing. I need a forward-looking solution, which means 64bit.</p>