11

I recently started testing on a C# (4.0) app that uses ODP.NET (Oracle.DataAccess 4.112.3)

I set this project to target any platform and publish the app.

When I run the program on the client machine I receive:

Could not load file or assembly 'Oracle.DataAccess, Version=4.112.3.0,Culture=neutral,
PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load 
a program with an incorrect format.

Like I said I've targeted 'Any CPU' and I've also embedded the Oracle.DataAccess assembly with the app.
I get this error on machines that have the Oracle client installed as well as machines that do not.

Any help is appreciated.

Wjdavis5
  • 3,566
  • 7
  • 27
  • 60

4 Answers4

18

Like I said I've targeted 'Any CPU'

This is likely the problem.

The Oracle.DataAccess has separate versions for 32bit and 64bit systems. If you are developing on a 32bit machine, and then deploying on a 64bit OS, you will receive this message.

You could easily work around this by building your application to target x86, and deploying the 32bit version of the data access components.

Reed Copsey
  • 522,342
  • 70
  • 1,092
  • 1,340
  • 1
    For web applications this means the app pool must run 32-bit and the 32-bit Oracle Client is required. What is the solution for 64-bit web server and oracle client, when using `4.112.3`? Copy local is 32-bit. Boom. Without it, the client's GAC'd copy `4.112.2` is used. Boom. Copying 64-bit new version to bin blows up saying its provider factory is missing an interface. Is it trying to use old GAC_64 version again? Or is something missing from `web.config` to tell it to use the new provider in the `bin` copy? – one.beat.consumer Nov 27 '12 at 21:47
4

As Reed Copsey said, there are two different DLLs. When you target ANYCpu, your app will run in 64 bit on a 64 bit machine, and 32 bit on a 32 bit machine. Therefore, if you want your app to work on 32 or 64 bit and run in AnyCPU mode, you should change the reference of Oracle.DataAccess to Specific Version=false and copy local = false. When you deploy to a client, they should have the oracle dll in the their GAC and it should pick up the correct version automagically.

aquinas
  • 21,814
  • 5
  • 51
  • 78
0

You should perhaps check if the Oracle.DataAccess assembly has any dependencies in your machine and that it is missing in the client machine.

Soundararajan
  • 1,756
  • 18
  • 22
0

From debug Any cpu at top change the optin to debug X64, though internally Any CPu points to X64 only but that does not work, try to change it to x64 and it should work like a charm