如何使 ODP.NET 4.0(64 位)在 64 位机器 Windows 7 上工作?

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

How to Make ODP.NET 4.0 (64 bit) working on 64 bit machine Windows 7?

asp.netwindowsodp.net

提问by user788312

I have installed the Oracle Client for the 64 bit machine using the XCopy 11.2 provided by Oracle (Installed everything as per the read me instructions).

我已经使用 Oracle 提供的 XCopy 11.2 为 64 位机器安装了 Oracle 客户端(按照自述说明安装了所有内容)。

I am using Visual Studio 2010 and the project is of type ASP.NET Website.

我使用的是 Visual Studio 2010,该项目的类型是 ASP.NET 网站。

When I tried to execute my ASP.NET Website using the Oracle Connection installed above..it is giving me the error from the web.config file during compile time.

当我尝试使用上面安装的 Oracle Connection 执行我的 ASP.NET 网站时..它在编译时给我来自 web.config 文件的错误。

**

**

"Could not load file or assembly 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified"

“无法加载文件或程序集 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' 或其依赖项之一。系统找不到指定的文件”

**

**

It worked if I changed the value of Enable 32-Bit Applications to True in IIS App pool.

如果我在 IIS 应用程序池中将启用 32 位应用程序的值更改为 True,它会起作用。

But my requirement is to make it work on 64 bit machine with 64 bit ODP.NET connector, So I do not want to change the value of Enable 32-Bit Applications to True.

但我的要求是让它在带有 64 位 ODP.NET 连接器的 64 位机器上工作,所以我不想将 Enable 32-Bit Applications 的值更改为 True。

So, If you could please help me finding an answer that would be greatly appreciated. Please help me fixing the above error.

所以,如果你能帮我找到一个答案,我将不胜感激。请帮我修复上述错误。

回答by devdimi

The best possibility to handle this is to use the x86 version locally with Visual Studio and x64 version on the server with IIS. To do this you have to download both versions - copy one in folder lib\x86 and the other in lib\x64 After this you have to modify the project file(s) - visual studio supports conditional references. Add following section to your project file:

处理此问题的最佳可能性是在本地使用带有 Visual Studio 的 x86 版本和带有 IIS 的服务器上的 x64 版本。为此,您必须下载两个版本 - 在文件夹 lib\x86 中复制一个,在 lib\x64 中复制另一个 在此之后,您必须修改项目文件 - Visual Studio 支持条件引用。将以下部分添加到您的项目文件中:

<PropertyGroup>
     <ReferencesPath Condition=" '$(Platform)' == 'x86' ">..\Lib\x86</ReferencesPath>
     <ReferencesPath Condition=" '$(Platform)' == 'x64' ">..\Lib\x64</ReferencesPath>
</PropertyGroup>

After this reference the odp.net assmebly like this:

在此参考 odp.net assmebly 之后,如下所示:

<Reference ... processorArchitecture=$(Platform)">
   <SpecificVersion>False</SpecificVersion>
   <HintPath>$(ReferencesPath)\Oracle.DataAccess.dll</HintPath>
   <Private>True</Private>
</Reference>

This way when you can build locally as x86 and on the server x64 and always the correct version of Oracle.DataAccess.dll will be referenced.

这样,当您可以在本地构建为 x86 并在服务器 x64 上构建时,将始终引用正确版本的 Oracle.DataAccess.dll。

Alternatively if you only want to use the x64 version than you have to stick to IIS even you work locally OR you could try to run the open source version of Cassini in x64 mode (http://cassinidev.codeplex.com).

或者,如果您只想使用 x64 版本而不必坚持使用 IIS,即使您在本地工作,或者您可以尝试在 x64 模式下运行开源版本的 Cassini (http://cassinidev.codeplex.com)。

For me the best possibility is to reference both versions as described above - this has been working fine for everyone on my team for a while now.

对我来说,最好的方法是参考上述两个版本——这对我团队中的每个人来说都已经有一段时间了。

回答by Hüseyin Ya?l?

You must install 64-bit Oracle Data Access Components (ODAC)since the Oracle Client Installation doesn't register Oracle.DataAccess.dll into the assembly.

您必须安装64 位 Oracle 数据访问组件 (ODAC),因为 Oracle 客户端安装不会将 Oracle.DataAccess.dll 注册到程序集中。

If your oracle data access installation is OK, everything should work after unchecking "Enable 32 bit applications" in your Application Pool settings.

如果您的 oracle 数据访问安装正常,则在您的应用程序池设置中取消选中“启用 32 位应用程序”后,一切都应该可以正常工作。

If you still have the same error, it is possible that you have a 32 bit dll in your bin folder of the website. Just delete it and the website will use the 64 bit from the assembly and it should work.

如果仍然出现相同的错误,则可能是网站的 bin 文件夹中有 32 位 dll。只需删除它,网站将使用程序集中的 64 位,它应该可以工作。