Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle.DataAccess.Dll loading issue on x-64 machine

I have a .net exe program which is using Oracle.DataAccess, Version=2.121.1.0 dll.

My development machine and tfs build server both are 32-bit. Everything is working fine on 32 machines. But now I have to migrate this program on x64 (Windows Server 2012 R2) and my all problems started from there.

I am getting the famous error

Could not load file or assembly 'Oracle.DataAccess, Version=2.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies..

I googled a lot and tried various things so far:

 1. Specifically build the executeble to target X86 platform  
    by changing the project properties Compile option
 2. I have installed the Oracle dll on the machine  
    and it's successfully registered in the GAC
 3. Tried to build the executable to target 'Any CPU' 
    and when it didn't work tried X64 as well
 4. Specifically supplied the assembly binding information in app.config file 
    to look at the exact place for loading the dll.
 5. Turned on the Fusion log to see the exact failure cause

Please see the error log below:

29/01/2015 10:57:30;ALERT ;System.Exception caught in Main() 
29/01/2015 10:57:30;ERROR ;System.BadImageFormatException: 
Could not load file or assembly 'Oracle.DataAccess, Version=2.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' 
or one of its dependencies. An attempt was made to load a program
with an incorrect format. 
File name: 'Oracle.DataAccess, Version=2.121.1.0, 
Culture=neutral, PublicKeyToken=89b483f429c47342' at XXXX.Common.Components.OraDataAccess..ctor() at 
XXXX.Library.ValuesCore.ValuesCore..ctor() at XXXX.Library.DerivationsCore.Derivations..ctor() at XXXX.Processes.XXXX.Main.Main() 
=== Pre-bind state information === 
LOG: User = XX 
LOG: DisplayName = Oracle.DataAccess, Version=2.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342 (Fully-specified) 
LOG: Appbase = file:///D:/Release/ 
LOG: Initial PrivatePath = NULL Calling assembly : XXXX.CommonComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e9b31bf34182bd8b. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: D:\Release\XXXX.exe.Config 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config. 
LOG: Post-policy reference: Oracle.DataAccess, Version=2.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342 
LOG: Attempting download of new URL file:///C:/Oracle/odp.net/bin/2.x/Oracle.DataAccess.dll. 
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated. 29/01/2015 10:57:30;
ERROR ;Could not load file or assembly 'Oracle.DataAccess, Version=2.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' 
or one of its dependencies. An attempt was made to load a program with an incorrect format. 
29/01/2015 10:57:30;ALERT ;(Global) Point Source ID = 0, Calc Time = 29/01/2015 10:57:30. 29/01/2015 10:57:30;STOP ;

Any help would is desparately needed and will be greatly appreciated.

Thanks

like image 414
binu Avatar asked Nov 14 '25 14:11

binu


1 Answers

The architecture (x86 or x64) of Oracle.DataAccess.dll must match the architecture of installed Oracle Client and both of them must match the architecture of your deployed application (i.e. whether you compiled at "AnyCPU" or "x86" or "x64").

"AnyCPU" will target to x64 on a 64-bit Windows.

The best solution is to install both x86 and x64 Oracle Client (and according ODP.NET) on your machine, then any combination will work. Here is an instruction how to do this: Install Oracle x86 and x64

An alternativ solution is to use the ODP.NET Managed Driver, this works in any case. You can download it from here: 64-bit Oracle Data Access Components (ODAC) Downloads

like image 185
Wernfried Domscheit Avatar answered Nov 17 '25 05:11

Wernfried Domscheit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!