C# Oracle.DataAccess 版本无法加载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12541119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle.DataAccess version could not load
提问by Adil Mammadov
I am having trouble with Oracle.DataAccessin WPF. I used Oracle.DataAccess v4.0without any problems. But now it updated to version 4.112 and when I add reference to this version in WPFthe designer could not be loaded. It gives me the following error:
我在使用Oracle.DataAccessin时遇到问题WPF。我使用Oracle.DataAccess v4.0没有任何问题。但是现在它更新到版本 4.112,当我在WPF设计器中添加对此版本的引用时无法加载。它给了我以下错误:
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
请注意,程序运行没有任何问题。我读到这可能是由于属性中的“目标 cpu”。我测试了 x64 和 x86,但没有任何变化。我怎么解决这个问题。提前致谢
采纳答案by Adil Mammadov
The problem was with my Oracle.DataAccess.dllfile. I have downloaded ODAC 11 XCopyand 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.
问题出在我的Oracle.DataAccess.dll文件上。我已经下载了ODAC 11 XCopy并将 Oracle.DataAccess.dll 从 \odp.net4\odp.net\bin\4 复制到我的 OracleClient 的 \odp.net\bin\4 文件夹并替换了 dll。现在它就像一个魅力。
Hope it will be helpful to someone else
希望对其他人有帮助
回答by Jignesh Thakker
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?
我遇到了通过将依赖项 DLL 放入 Oracle.DataAcces 解决的相同问题。检查此链接使用 Oracle 客户端 11 部署 .NET 应用程序所需的最小设置是什么?
Hope It should help.
希望它应该有所帮助。
回答by Elijah W. Gagne
I've dealt with this problems way too many times. Below is some PowerShell that I routinely use to deploy an app.
我已经处理过太多次这个问题了。下面是一些我经常用来部署应用程序的 PowerShell。
$target = "\SERVER\c$\PROJECT"
$oracleBin = "C:\oracle\product.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:
我可以为努力解决这个问题的人添加两个注释:
- 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.
- 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.
- 您可以根据您在 Visual Studio 中引用 Oracle.DataAccess.dll 的位置找到正确的 Oracle 主目录(即您的 client_1\bin 所在的位置)。我有多个 Oracle 主目录,所以这一直是我不得不解决的问题。
- 以上适用于 Oracle 11g。如果您有 Oracle 12c,我相信类似的过程会起作用,但某些文件名从 *11.dll 更改为 *12.dll。


回答by Sunil
Another solution is to download and execute the install.bat file in 'ODAC112030Xcopy.zip' from 64-bit Oracle Data Access Components (ODAC) Downloads.
另一种解决方案是从64 位 Oracle 数据访问组件 (ODAC) 下载下载并执行“ODAC112030Xcopy.zip”中的 install.bat 文件。

