One of our dev team member got an error
Attempt to load oracle client libraries threw BadImageFormatException
It seems
This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
But it was me who configured the system - Here's the specifications:
- Windows 7 64-bit
- Visual Studio 2010 Premium
- Oracle Client 11g R2 64Bit installed as Runtime
Any thoughts?
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 :)
The quick and easy solution for this problem you have to follow the below steps only:
- Install ODACv11.2021Xcopy_x64, by run install.bat file then check "c:\oracle" as created path.
- copy your Network configuration folder [that contain admin folder with tnsnames.ora file] in oracle 32bit to "c:\oracle".
- 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.
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:
- Connect oracle database using server explore (where connection string will be created and which can be used while adding model)
- Add model using existing connectionstring (created in step1).
But i was struck in step 1 itself with BadImageFormatException warning and I found solution. Resolution:
- Follow the instruction given in link and complete the oracle client installation http://www.oracle.com/technetwork/topics/dotnet/whatsnew/vs2012welcome-1835382.html
- 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 :)
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
来源:https://stackoverflow.com/questions/5869969/badimageformatexception-while-using-oracle-client-64-bit-and-visual-studio-2010