0

I've an issue with a service we've got here.

I've had this error :

System.IO.FileNotFoundException : Could not load file or assembly 'Oracle.DataAccess, Version=4.112.4.0, Culture=neutral, PublicKeyToken=X' or one of its dependencies.' 

So I guessed I'd add the dll in the bin folder of my project, nothing much, right ?

Then I had this error :

Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Okay, I've seen this before, just go to the application pool and set "Enable 32bit applications" to true.... Right ?

OpenDBConnection: Error occurred. System.TypeInitializationException: 
The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. 
---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client

Okayyy... No problem, let me check : the server is a 2008 R2 enterprise x64. I'll compile to x64 then.

Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Now, this mess has last for the last few days. I'm getting mad, cause I'm obviously turning in circle but can't figure where the exit is.

I've Oracle 1120_32 and 1120_64 installed (that's 11.2.0.2.0 version), .Net 4.0 installed. I've tried compiling to "any cpu". I've tried setting the dll properties to "Specific version = false", "Copy Local = true", as well as the opposite. I've tried getting old versions of the program and re-compile them after making the needed changes in the code, keeping the old config. I've tried dancing round a cactus singing "Please, Big Bill, Let this DLL be loaded".

I've checked many links, but this happen in a remote environment, so I don't have the option to set a breakpoint or whatever to see WHICH dll the program tries to load, and most links advise to (re)install oracle client on the server, but as I'd have to ask the admin for this, I would rather have the confirmation there's nothing else last to try.

Could someone help please ?

DoctorPrisme
  • 93
  • 11
  • How did you install 32-bit and 64-bit Oracle Client? Have a look at this instruction: http://stackoverflow.com/questions/24104210/badimageformatexception-this-will-occur-when-running-in-64-bit-mode-with-the-32#24120100, resp. http://stackoverflow.com/questions/659341/the-provider-is-not-compatible-with-the-version-of-oracle-client#25412992 – Wernfried Domscheit Feb 10 '17 at 15:11
  • @WernfriedDomscheit well I'm not the server admin, so I did not install anything :) As said in the post, I've already seen posts saying reinstalling 'might' do the trick, but I'm hoping for something else... – DoctorPrisme Feb 10 '17 at 15:17
  • Sounds strange, but I had something similar a while back with VS2013 I believe. The fix was to remove (delete) the reference in VS and then add it back (32-bit odac). – tbone Feb 10 '17 at 21:24
  • @tbone I tried that already. I believe the program loads another DLL present on the server, but I can't check which one... So I don't know where to clean it :( – DoctorPrisme Feb 13 '17 at 07:19

1 Answers1

0

If the app pool has 32-bit enabled then the oracle client and the application need to also be 32-bit.

I think the managed ODAC would be less painful.

If you want to go 64-bit, make sure everything is 64 bit (App, app pool and Odac)

Also, Windows Sysinternals Process Monitor can be useful to determine which unmanaged dll are being loaded by the Oracle.DataAccess.dll used by your app.

  • I don't know what you mean by Managed ODAC. I have both oracle client 32 and oracle client 64 installed, my question is really "how to force the program to load this particular dll", as it seems it tries to use an old one. Thank you – DoctorPrisme Feb 13 '17 at 07:20
  • The Managed odac is a different download see [link](http://www.oracle.com/technetwork/database/windows/downloads/utilsoft-087491.html), it doesn't need all the unmanaged client dlls installed. The unamanged odac uses registry keys and environment paths and vars to determine which client to use. – Julian Perrott Feb 14 '17 at 13:51
  • BadImageFormatException: Could not load file or assembly 'NameOfYourAppHere' or one of its dependencies. An attempt was made to load a program with an incorrect format. This means that there is a bitness mismatch between the Application pool and the application or the application and the Oracle.DataAccess.dll. IF App Pool has enabled 32bit apps then the app is compiled in x64 or oracle.dataaccess.dll is x64. or if if App Pool has not enable 32bit Apps then App compiled in x86 or oracle.dataaccess.dll is x86 (App pool doesn’t support x86) – Julian Perrott Feb 14 '17 at 13:52
  • BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format. HttpException (0x80004005): Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format. The application is complied in x86, but the Oracle.DataAccess.dll is x64 – Julian Perrott Feb 14 '17 at 13:52
  • OracleException (0x80004005): The provider is not compatible with the version of Oracle client. The App pool, application and Oracle.DataAccess.dll are all 32 bit, but the ODP.NET installed on the machine is 64-bit – Julian Perrott Feb 14 '17 at 13:52
  • I have downloaded and referenced the managed Oracle ,( but I could not test it as other tests are currently run on the server.) Is there somehting else to do to configure it than add a reference? Does it risk to cause compatibility issues? The error you've listed are not related to my issue. I've never seen the badimageformatexception, and as t the oracleException, since I have both odp.net 64 and 32 bit, I presume that's not the cause either. – DoctorPrisme Feb 15 '17 at 13:23