Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
To all,

I know there is a solution to this problem on this website but it is not working for me.
I am new to web development and am probably doing something very basic wrong.
I am running Windows 7 64-bit and Visual Studio 2008.

I am porting a WPF application to a web application. The application uses Oracle Client to connect to the database. Upon connection (.Open()), it is throwing the error:

"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."

I am running the web application on my desktop and not on a server at this point. The desktop application connects to the database fine and uses the 32-bit version of the OracleClient dll located in the folder:

Windows\Microsoft.NET\Framework\v2.0.50727

The IIS is set to this version (v2.050727) and Enable 32-bit applications is set to false.

I have tried using the 32-bit Oracle Client and the 64-bit version located:

Windows\Microsoft.NET\Framework64\v2.0.50727

I continue to get the same error.

If anyone can help, I would greatly appreciate it.

Thanks in advance,
Gloria
Posted

1 solution

You cannot mix the assemblies (or unmanaged modules) with different instruction-set architectures in a single process. Check up each and every module. Normally, if you build all the assemblies as "AnyCPU", the ultimate instruction-set architectures actually used during runtime will be defined by the actual architecture of the machine.

Note that on all 64-bit systems, 32-bit process will work via WoW64:
http://en.wikipedia.org/wiki/WOW64[^].

At the same time, different 64-bit architectures wull also conflict: x86-64 and Itanium (I-64).

I cannot imagine the situation when you might need the target instruction-set architecture other then AnyCPU in a Web application.

See also: http://en.wikipedia.org/wiki/Instruction_set[^].

—SA
 
Share this answer
 
v2
Comments
Member 9454834 7-May-13 11:04am    
Thanks for your quick response.
I checked the Configruation Manager and the project platform is set to 'AnyCPU'.
I switched the OracleClient assembly back to the 32-bit version and it does not work still.
All of the other assemblies are 'System.' assemblies and not home-grown assemblies. How do you check if they are set to 'AnyCPU'?
Sergey Alexandrovich Kryukov 7-May-13 11:10am    
There should be something else which conflicts. When you say "System..." you probably mean the .NET Assemblies from FCL. They are put to GAC and are selected by a strong name with "automatically" correct target platform.

I don't know what conflicts, but there is something. Do one experiment: set everything to x86 and 32-bit and check up if it works. Of course, use 32-bit Oracle client...

—SA
Member 9454834 7-May-13 11:18am    
Yes. By 'System' assemblies, they are the .NET assemblies.
I changed the Oracle Client to x86 by selecting the dll in the folder:
C:\Windows\Microsoft.NET\Framework\v2.050727

I get the same error...
{"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."}

Can you think of anywhere else there can be a conflict?
Thanks
Sergey Alexandrovich Kryukov 7-May-13 11:29am    
What do I see?! Do you really use the DLLs from C:\Windows\Microsoft.NET\Framework\v2.050727?!
This is the problem. Never do it! Assemblies are in GAC, you should add them by strong name, not by a location of the executable module.

Did you do such things before? Is so, let me give you some good news: you haven't done any programming, all you did was a complete mess.
You should reference GAC assemblies by strong names. Read:
http://en.wikipedia.org/wiki/Global_Assembly_Cache
http://en.wikipedia.org/wiki/Strong_name

Practically, with Visual Studuo, you should add references using the tab ".NET" of the "Add Reference" window, not "Browse".

—SA
Member 9454834 7-May-13 11:49am    
I did that originally...
Went to the .NET tab and selected the OracleClient.
Only when I had trouble with the error that I looked deeper into what assembly was being added.
Looking to the path in the .NET tab, this is where the DLL is coming from:
Windows\Microsoft.NET\Framework\v2.050727.
Again, troubleshooting the problem, I found a folder for what I believe to be the 4-bit libraries (Framework64) and tried those and the problem still persists.

I am loading the same dll whether I go thru .NET tab or the Browse Tab.

There must be another conflict.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900