Oracle – Could not load file or assembly ‘Oracle.DataAccess’ 64 bit ODP.NET

asp.netodp.netoracle

I am using ODP.NET in my asp.net project in order for the application to talk to oracle 11 g Express on Windows 2008 server (32 bit). While on development machine I had Windows 7 (32 bit). I installed Windows 8 (64 bit) on the development machine and tried to run the application from visual studio 2012, It gave the error 'Could not load file or assembly 'Oracle.DataAccess''. After a little search I realized that I have to install ODP.NET (64 bit) in order to use it on 64-bit machine, so I uninstalled the 32 bit version and installed 64-bit ODP.NET. Removed the reference to old Oracle.DataAccess but still facing the same issue. Am I missing something??

Best Answer

I had the same issue and after some trial and error I found that the issue is with 32 bit vs 64 bit platform.

  1. When we deploy 32 Bit Oracle.DataAccess.dll along with web application over 64 bit environment and ODP.net installed over server this error will occur.
  2. One solution is to delete the Oracle.DataAccess.dll from bin folder and correct reference will be auto resolved.
  3. Second solution is to set the reference property CopyToLocal=false for Oracle.DataAccess.dll and hence it wont go with build when you deploy on IIS and error will not occur.
  4. Third solution which I will prefer is to enable 32 bit applications for your application pool and you wont face this issue again irrespective of whether Oracle.DataAccess.dll is present in bin folder or not.

Hope this helps..