0
votes

I have to set a few projects in our VS 2005 solution to build to x64 only. The 3rd party software the projects are using requires it.

The Oracle DLL (System.Data.OracleClient.dll) the project is referencing reside in Windows\Microsoft.NET\Framework\v2.0.57027 which causes issues when connecting to oracle from a 64bit project.

Is there a reason why Microsoft is not using the Framework64\v2.0.50727 directory to reference the System.Data.OracleClient.dll? The project is forced to build to x64, so logically one would think it would use the Framework64 references.

The error I'm getting is:

System.InvalidOperationException : 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. ----> System.BadImageFormatException : An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Whenever I go to add a reference, it's only referencing the non-64bit DLL's. Will I need to hard reference the 64bit System.Data.OracleClient.dll?

Thanks.

1

1 Answers

1
votes

This doesn't have anything to do with reference assemblies. The compiler always uses 32-bit assembly reference. Which is fine, it only uses the metadata in the assembly which is the same for 32-bit and 64-bit code.

What goes wrong here is the kind of assembly it finds at runtime. The 32-bit ones by the sound of it. Common problem with Oracle, they don't like to use the GAC for some reason. And their assemblies contain unmanaged code so can't run either way. You'll need to either deploy the 64-bit version of the Oracle provider or force your program to run in 32-bit mode. Contact Oracle for support if you can't sort it out.