Oracle.DataAccess不匹配错误 [英] Oracle.DataAccess mismatch error

查看:72
本文介绍了Oracle.DataAccess不匹配错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

'正在构建的项目"MSIL"的处理器体系结构与参考Oracle的处理器体系结构之间不匹配.DataAcess,版本4.112.3.0,Culture = neutral,PublicKeyToken = 89b483f429c47342,processorArchitecture = x86,"x86 ".这种不匹配可能会导致运行时失败.请考虑通过Configuration Manager更改项目的目标处理器体系结构,以使您的项目与引用之间的处理器体系结构保持一致,或者将引用依赖于与项目的目标处理器体系结构相匹配的处理器体系结构.

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

解决方案

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

我确实找到了连接文章对此可能包含更改(我假设是proj文件)以禁用该错误:

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

无论如何,只要您在服务器上安装的32位odp.net与您引用的64位odp.net的版本相同,"AnyCPU"应用程序就可以在服务器上正常运行.正确安装以重定向到更高版本).为了消除任何混乱,我通常将"Copy Local"设置为对"false"的引用.换句话说,我针对特定版本的dll进行编译,但让它针对GAC解析的内容运行(其中包括大多数odp.net安装所包含的发布商政策).

您还可以在您的开发机器上安装32位odp.net(最好是同一版本),以便运行/调试32位应用程序或使用"Oracle Developer Tools for Visual Studio"附带的集成工具.在Visual Studio中.

总而言之,这里不仅有吸引人的目光.如果您的应用程序实际上正在以64位运行(暗示这只是一个警告"),则不是使用32位安装.我猜您的计算机已经安装了64位版本(多个oracle目录).

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.

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)

'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'

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

解决方案

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.

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

<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).

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.

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).

这篇关于Oracle.DataAccess不匹配错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆