简体   繁体   English

C#ODP.NET加载文件或程序集

[英]C# ODP.NET Load file or assembly

I recently started testing on a C# (4.0) app that uses ODP.NET (Oracle.DataAccess 4.112.3) 我最近开始测试使用ODP.NET的C#(4.0)应用程序(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. 就像我说的那样,我的目标是“任何CPU”,我还在应用程序中嵌入了Oracle.DataAccess程序集。
I get this error on machines that have the Oracle client installed as well as machines that do not. 我在安装了Oracle客户端的计算机上以及没有安装Oracle客户端的计算机上出现此错误。

Any help is appreciated. 任何帮助表示赞赏。

Like I said I've targeted 'Any CPU' 就像我说我已经针对'任何CPU'

This is likely the problem. 这可能是问题所在。

The Oracle.DataAccess has separate versions for 32bit and 64bit systems. Oracle.DataAccess具有32位64位系统的单独版本。 If you are developing on a 32bit machine, and then deploying on a 64bit OS, you will receive this message. 如果您使用32位计算机进行开发,然后在64位操作系统上进行部署,则会收到此消息。

You could easily work around this by building your application to target x86, and deploying the 32bit version of the data access components. 您可以通过构建针对x86的应用程序以及部署32位版本的数据访问组件来轻松解决此问题。

As Reed Copsey said, there are two different DLLs. 正如Reed Copsey所说,有两种不同的DLL。 When you target ANYCpu, your app will run in 64 bit on a 64 bit machine, and 32 bit on a 32 bit machine. 当您以ANYCpu为目标时,您的应用程序将在64位计算机上以64位运行,在32位计算机上以32位运行。 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. 因此,如果您希望应用程序在32位或64位上运行在AnyCPU模式下运行,则应将Oracle.DataAccess的引用更改为Specific Version = false并复制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. 当您部署到客户端时,他们应该在他们的GAC中拥有oracle dll,它应该自动获取正确的版本。

您应该检查Oracle.DataAccess程序集是否在您的计算机中具有任何依赖项,并且在客户端计算机中是否缺少该依赖项。

从调试顶部的任何cpu更改optin调试X64,虽然内部任何CPu只指向X64,但这不起作用,尝试将其更改为x64,它应该像魅力一样工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM