BadImageFormatException while using Oracle Client 64 bit and Visual Studio 2010!

谁说我不能喝 提交于 2019-12-03 00:09:54

I have seen this a couple of times recently when running Visual studio on a 64Bit O/S. A simple workround is to install the 32bit client on your 64Bit development machine.

Regards, Pete

I am sorry about adding a second answer but if you have 64 bit and 32 bit clients installed in the same machine you may encounter this problem too.

Two clients installed

C:\oracle\product\11.2.0\client32Bit
C:\oracle\product\11.2.0\client64Bit

Control your path Environment Variable. Which Oracle client is first, it is loaded before other one.

 echo %PATH%
 XXXX;C:\oracle\product\11.2.0\client64Bit\BIN;XXX

Since my 64bit Oracle Client is first in PATH, VS.NET tries to use it for Oracle Connections and throws Bad Image Exception.

  set PATH=C:\oracle\product\11.2.0\client32Bit\BIN;%PATH%
  REM Visual Studio 2008
  "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
  REM Visual Studio 2010
  "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"

After this you can connect oracle. Of course you can put 32Bit client first in path but I prefer to put 64 bit client before 32 bit for other applications.

I had the same error after upgrading to Windows 7. I resolved it by changing the Platform target to x86 in the Build tab of the Properties page in Visual Studio

Same problem you may face also in Visual Studio 2013 and 64-bit Oracle Client (11 and 12 versions). My solution is:

a) Desktop project. Project properties > Build > disable 'Prefer 32-bit' checkbox.

b) ASP.NET project or web site. Main menu > TOOLS > Options > Project and Solutions > Web Projects > enable 'Use the 64 bit version of IIS Express for web sites and projects' checkbox.

I changed 32 bit enabled support to FALSE in my Application pool in IIS7. This worked for me. I found it easy. Cheers :)

Nawaf

The quick and easy solution for this problem you have to follow the below steps only:

  1. Install ODACv11.2021Xcopy_x64, by run install.bat file then check "c:\oracle" as created path.
  2. copy your Network configuration folder [that contain admin folder with tnsnames.ora file] in oracle 32bit to "c:\oracle".
  3. Added the "c:\oracle" path to the PATH environment variable.

enjoy

Best Regards, Eng. Nawaf H. Bin Taleb.

I got the same exception and I found out that it occurred when I upgraded to MVC version higher than 2.0., in my case MVC 4.0.

Creating a new project in MVC 2.0 resolved the issue.

Hüseyin Yağlı

If you want to use 64 bit see my answer here:
64 bit Oracle DataAccess configuration

If you are content with 32 bit, just install the 32 bit version of Oracle Data Access Components. Since the development server of Visual Studio is 32 bit, you won't have any problems.

Simple solution: works for me. try this.

I spent almost 4 hours to find the solution for BadImageFormatException issue.

Scenario: VS 2012, i was trying to add entity model to Oracle database first time. I knew that there are two steps to add model for oracle database:

  1. Connect oracle database using server explore (where connection string will be created and which can be used while adding model)
  2. Add model using existing connectionstring (created in step1).

But i was struck in step 1 itself with BadImageFormatException warning and I found solution. Resolution:

  1. Follow the instruction given in link and complete the oracle client installation http://www.oracle.com/technetwork/topics/dotnet/whatsnew/vs2012welcome-1835382.html
  2. Once installation completed successfully, then simple step ie. add model to project. here use existing connection string from dropdownlist and provide userid/pwd.

then you are ready to use model :)

Rick

I had the same problem and that solution that Muru's shared worked to me:

http://www.oracle.com/technetwork/topics/dotnet/whatsnew/vs2012welcome-1835382.html

Just install ODAC and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!