5

I am having trouble with Oracle.DataAccess in WPF. I used Oracle.DataAccess v4.0 without any problems. But now it updated to version 4.112 and when I add reference to this version in WPF the designer could not be loaded. It gives me the following error:

System.BadImageFormatException
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.

Please note that program runs without any problem. I read that it can be due to "target cpu" in properties. I tested both x64 and x86 but nothing changes. How can I solve this problem. Thanks in advance

Nick Krasnov
  • 26,886
  • 6
  • 61
  • 78
Adil Mammadov
  • 8,476
  • 4
  • 31
  • 59

4 Answers4

6

The problem was with my Oracle.DataAccess.dll file. I have downloaded ODAC 11 XCopy and copied Oracle.DataAccess.dll from \odp.net4\odp.net\bin\4 to my OracleClient's \odp.net\bin\4 folder and replaced dlls. Now it works like a charm.

Hope it will be helpful to someone else

Adil Mammadov
  • 8,476
  • 4
  • 31
  • 59
3

I faced same issue I solved by putting dependencies DLL to Oracle.DataAcces. check this link What is the minimal setup required to deploy a .NET application with Oracle client 11?

Hope It should help.

Community
  • 1
  • 1
Jignesh Thakker
  • 3,638
  • 2
  • 28
  • 35
  • What should I do? Copy all this ddls to all of my WPF applications? – Adil Mammadov Sep 22 '12 at 07:19
  • Yes. Put it in application Debug or Release folder. No need to reference it only required to put with Oracle.DataAccess.dll – Jignesh Thakker Sep 22 '12 at 07:26
  • Ok. Thank you. But they don't talk about WPF design mode they are talking about Deploying or setting up program. But I will try. Hope it will help – Adil Mammadov Sep 22 '12 at 07:39
  • Yes. link talking about Deploying. I created application in WinForm. I faced same issue like your. but after putting dependencies dlls It's worked perfectly. try by putting dlls. – Jignesh Thakker Sep 22 '12 at 07:42
  • you can find dlls in OraHome\BIN – Jignesh Thakker Sep 22 '12 at 07:52
  • I did what is written. But I can't find oraociicus11.dll anywhere. And there is no change in my project – Adil Mammadov Sep 24 '12 at 04:58
  • I don't know exact location right now. I m with different PC right now. you can try to search oraociicus11.dll in your operating system drive. Hope you can find. and Thanks for above solution I will also try with my old application. – Jignesh Thakker Sep 24 '12 at 05:50
0

I've dealt with this problems way too many times. Below is some PowerShell that I routinely use to deploy an app.

$target = "\\SERVER\c$\PROJECT"
$oracleBin = "C:\oracle\product\11.2.0\client_1\BIN\"
$projectHome = "C:\Users\USER\Code\CSharp\PROJECT\bin\Release\"
$files = @(
($oracleBin + "oci.dll"),
($oracleBin + "orannzsbb11.dll"),
($oracleBin + "oraocci11.dll"),
($oracleBin + "OraOps11w.dll"),
($projectHome + "EntityFramework.dll"),
($projectHome + "EntityFramework.xml"),
($projectHome + "Oracle.DataAccess.dll"),
($projectHome + "PROJECT.exe")
#,($projectHome + "PROJECT.exe.config")
)
foreach($f in $files) {
    copy-item $f $target
}

Two notes I can add for someone struggling to solve this problem:

  1. You can find the correct Oracle home (i.e. where your client_1\bin is), based on where you're referencing Oracle.DataAccess.dll from within Visual Studio. I have multiple Oracle homes so that's been an issue I've had to overcome a few times.
  2. The above works for Oracle 11g. If you have Oracle 12c, I believe a similar process will work, but some of the file names change from *11.dll to *12.dll.

enter image description here

Elijah W. Gagne
  • 2,801
  • 4
  • 31
  • 29
0

Another solution is to download and execute the install.bat file in 'ODAC112030Xcopy.zip' from 64-bit Oracle Data Access Components (ODAC) Downloads.

Sunil
  • 2,885
  • 5
  • 34
  • 41