Oracle.DataAccess 不匹配错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14638067/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:25:22  来源:igfitidea点击:

Oracle.DataAccess mismatch error

oracleodp.net

提问by MrMVCMan

I installed the odp.net 32 bit installation for Visual Studio 2012. I set a reference to the Oracle.DataAccess.dll and my connection to Oracle seems to be working.

我为 Visual Studio 2012 安装了 odp.net 32​​ 位安装。我设置了对 Oracle.DataAccess.dll 的引用,我与 Oracle 的连接似乎正常工作。

When I build the project (.net 4) I get the following error. The project is set to build AnyCPU (my workstation is 64 bit and the server where we will ultimately deploy to is 32bit)

当我构建项目 (.net 4) 时,出现以下错误。该项目设置为构建 AnyCPU(我的工作站是 64 位,我们最终将部署到的服务器是 32 位)

'There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference Oracle.DataAcess, Version 4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86, "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architecture between your project and the references, or take a dependency on reference with a processor architecture that matches the targeted processor architecture of your project'

'正在构建的项目的处理器架构“MSIL”与参考 Oracle.DataAcess,版本 4.112.3.0,Culture=neutral,PublicKeyToken=89b483f429c47342,processorArchitecture=x86,“x86”的处理器架构之间存在不匹配。这种不匹配可能会导致运行时失败。请考虑通过配置管理器更改项目的目标处理器架构,以便使项目和参考之间的处理器架构保持一致,或者依赖与项目目标处理器架构匹配的处理器架构的参考”

This is only a vs.net warning however is there any way to get rid of this?

这只是一个 vs.net 警告,但是有什么办法可以摆脱它吗?

回答by b_levitt

Like you said, it's just a warning. Because ODP.net is not "AnyCPU" the warning indicates that you have a dependency that is not going to adapt to the host operating system as your own application is. As long as your odp.net install matches the os in terms of bits, you'll be fine. But the compiler is unable to make that determination and is trying to give you a heads up.

就像你说的,这只是一个警告。因为 ODP.net 不是“AnyCPU”,警告表明您的依赖项不会像您自己的应用程序那样适应主机操作系统。只要您的 odp.net 安装在位方面与操作系统匹配,您就可以了。但是编译器无法做出这个决定,并试图提醒您注意。

I did find a connect articleon this which includes a possible change (i'm assuming to the proj file) to disable the error:

我确实找到了一篇关于此的连接文章,其中包括一个可能的更改(我假设是 proj 文件)以禁用错误:

<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>

In any case, your "AnyCPU" application will run fine on your server as long as the 32 bit odp.net you install on the server is the same version as the 64 bit odp.net you referenced (or publisher policies are properly installed to redirect to a later version). To eliminate any confusion i generally set "Copy Local" for the reference to "false." In otherwords, I compile against a specific version of the dll but let it run against what it resolves from the GAC (which includes publisher policies that most of the odp.net installations include).

在任何情况下,只要您在服务器上安装的 32 位 odp.net 与您引用的 64 位 odp.net 版本相同(或发布者策略已正确安装到重定向到更高版本)。为了消除任何混淆,我通常将“Copy Local”设置为“false”的引用。换句话说,我针对特定版本的 dll 进行编译,但让它根据从 GAC 解析的内容运行(其中包括大多数 odp.net 安装包含的发布者策略)。

You can also install the 32 bit odp.net on your dev machine (ideally the same version again) in order to run/debug 32 bit applications or to use the integrated tooling that comes "with Oracle Developer Tools for Visual Studio" inside of Visual Studio.

您还可以在您的开发机器上安装 32 位 odp.net(最好再次使用相同的版本),以便运行/调试 32 位应用程序或使用 Visual Studio 中“带有 Oracle Developer Tools for Visual Studio”的集成工具工作室。

All that said, there's more than meets the eye here. If you're application is in fact running (which is implied with "it's only a warning"), as 64 bit, than it is NOT using your 32 bit installation. I would guess your machine already has the 64 bit version installed (multiple oracle homes).

话虽如此,这里的内容远不止眼前一亮。如果您的应用程序实际上正在运行(这暗示“它只是一个警告”),作为 64 位,那么它没有使用您的 32 位安装。我猜你的机器已经安装了 64 位版本(多个 oracle 家庭)。

回答by user3409326

Another solution:

另一种解决方案:

Download ODAC 11.2 Release 5 (11.2.0.3.20)and set your compiler to x86. I am 100 % sure it will clean all warnings related to oracle. Set namespace to: using System.Data.Odbc;

下载ODAC 11.2 第 5 版 (11.2.0.3.20)并将编译器设置为 x86。我 100% 肯定它会清除所有与 oracle 相关的警告。将命名空间设置为:using System.Data.Odbc;

Then make a database connection.

然后建立数据库连接。

回答by maialithar

This is only a vs.net warning however is there any way to get rid of this?

这只是一个 vs.net 警告,但是有什么办法可以摆脱它吗?

I believe there is no way to get rid of that, since you want to deploy on 32 bit machine and you create on 64 bit. This is just a warning that informs you that there may be sth wrong with the driver. Nothing to worry about if you now what you're doing.

我相信没有办法摆脱它,因为您想在 32 位机器上部署并在 64 位上创建。这只是一个警告,通知您驱动程序可能有问题。如果您现在正在做什么,则无需担心。

You should expect it - you use 32 bit libraries on 64 bit architecture.

您应该期待它 - 您在 64 位架构上使用 32 位库。