title: asp.net core Oracle.DataAccess System.BadImageFormatException: Could not load file or assembly Oracle.DataAccess
body: <p>I've added Oracle.DataAccess as reference to asp.net core project.
  I've only installed Oracle Data Provider for .Net when installed ODAC.
  I would like to make a simple example with Dapper on the project.</p>
  
  <pre><code>public class Program
  {
      const string connectionString = "xxxxx";
      public static void Main(string[] args)
      {
          IDbConnection connection = new OracleConnection(connectionString);
          string sql = "SELECT * FROM People WHERE  Name='JOHN'";
          var r = connection.Query&lt;People&gt;(sql);
      }
  }
  </code></pre>
  
  <p>The application wasn't running. I was getting this error below when I tried "dnx run" on the project folder.</p>
  
  <blockquote>
    <p>System.BadImageFormatException: Could not load file or assembly
    'Oracle.DataAccess, Version=4.121.2.0, Culture=neutral,
    PublicKeyToken=89b483f429c47342' or one of its dependencies. An
    attempt was made to load a program with an incorrect format.</p>
  </blockquote>
  
  <p>If you get this message, probably, it means Oracle.DataAccess dll doesn't exist in the GAC.</p>
  
  <ol>
  <li><p>Open Command Line and go to bin folder under the odp.net e.g. 
  <pre><code>cd C:\oracle\product\12.1.0\client_x86\odp.net\bin\4</pre></code></p></li>
  <li><p>Run this command below
  <pre><code>
  OraProvCfg.exe /action:gac /providerpath:C:\oracle\product\12.1.0\client_x86\odp.net\bin\4\Oracle.DataAccess.dll</pre></code></p></li>
  </ol>
  
  <p>After doing these steps I was able to run the project successfully.</p>