.net 使用 oracle.dataaccess.dll 时出错

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

Error using oracle.dataaccess.dll

.netwindowsoracle64-bitodp.net

提问by Zoliqa

I have a web application which uses Oracle.DataAccess.dll to communicate with an Oracle db. The web application deployed on 32 bit windows system works but not on windows server 2008 64 bit. I installed 10204_vista_win2k8_x64_production_db package, referenced the installed dll (version 2.102.4.0) from the project but I get the following error:

我有一个 Web 应用程序,它使用 Oracle.DataAccess.dll 与 Oracle 数据库通信。部署在 32 位 windows 系统上的 web 应用程序可以工作,但不能在 windows server 2008 64 位上运行。我安装了 10204_vista_win2k8_x64_production_db 包,从项目中引用了已安装的 dll(版本 2.102.4.0),但出现以下错误:

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

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

回答by Philippe Leybaert

Same here. The Oracle.DataAccess assembly doesn't run in 64 bit mode.

同样在这里。Oracle.DataAccess 程序集不在 64 位模式下运行。

You should set the application pool for your site to 32 bit mode (go to the application pool's Advanced Settingsand set Allow 32 Bit Applicationsto "True")

您应该将站点的应用程序池设置为 32 位模式(转到应用程序池的高级设置并将允许 32 位应用程序设置为“真”)

If that doesn't work, make sure your Oracle directory (the directory containing all the Oracle dlls) is in your system path. If you forget that, you get the same cryptic error about not finding Oracle.DataAccess.

如果这不起作用,请确保您的 Oracle 目录(包含所有 Oracle dll 的目录)在您的系统路径中。如果你忘记了这一点,你会得到同样的关于找不到 Oracle.DataAccess 的神秘错误。

EDIT:

编辑

Installing the Oracle client can be a major pain. Using the Oracle Instant Clientis somewhat easier than installing the full client, so this is what I usually do:

安装 Oracle 客户端可能是一个主要的痛苦。使用Oracle Instant Client比安装完整客户端要容易一些,所以我通常这样做:

  1. Download the Oracle Instant Client
  2. Unzip the archive in c:\oracle (any other directory will do)
  3. Open a command prompt as administrator
  4. type cd \oracle
  5. type configure odp.net20 myhome
  6. Right-click on "My Computer", "Advanced System Settings", "Environment Variables" and add the C:\oracle directory to the system path
  7. Copy the Oracle.DataAccess.dll file from c:\oracle\odp.net\bin\2.x to your application's bin folder
  8. (optonally) edit your c:\oracle\tnsnames.ora file
  1. 下载Oracle 即时客户端
  2. 解压缩 c:\oracle 中的存档(任何其他目录都可以)
  3. 以管理员身份打开命令提示符
  4. 键入cd \oracle
  5. 键入配置 odp.net20 myhome
  6. 右键单击“我的电脑”、“高级系统设置”、“环境变量”,将C:\oracle目录添加到系统路径
  7. 将 Oracle.DataAccess.dll 文件从 c:\oracle\odp.net\bin\2.x 复制到应用程序的 bin 文件夹
  8. (可选)编辑您的 c:\oracle\tnsnames.ora 文件

回答by John Banks

I'm going to give you the answers from what I've just went through on Windows Server 2008 R2 which is a 64 bit operating system. The application suite of libraries I was given were developed using .net 3.5 x86 with the older DLL libraries and I was stuck because I had installed the newer x64 clients from oracle.

我将根据我刚刚在 64 位操作系统 Windows Server 2008 R2 上的经历为您提供答案。我得到的应用程序套件库是使用 .net 3.5 x86 和较旧的 DLL 库开发的,我被卡住了,因为我从 oracle 安装了较新的 x64 客户端。

What I found was the following: Install the latest x64 client from Oracle for Windows Server 2008. I believe this would be the 2.7.0 client. When you select the installation, make sure you do custom and select the .NET libraries. Configure your tnsnames files and test your tnsping against your data source.

我发现如下: 从 Oracle 为 Windows Server 2008 安装最新的 x64 客户端。我相信这将是 2.7.0 客户端。选择安装时,请确保进行自定义并选择 .NET 库。配置您的 tnsnames 文件并针对您的数据源测试您的 tnsping。

Next, if you are running a 32 bit application, install the same version of the client for 32 bit. Also, follow the same installation routine, and select the same home.

接下来,如果您运行的是 32 位应用程序,请为 32 位安装相同版本的客户端。此外,遵循相同的安装程序,并选择相同的家。

When your finished, you will find that you have a single app/product with two client directories (Client1 and Client2).

完成后,您会发现您有一个带有两个客户端目录(Client1 和 Client2)的应用程序/产品。

if you navigate to the windows/assemblies directory you will find that you have a reference to the Oracle.DataAccess.dll (x2) with one for x86 and one for AMD64.

如果您导航到 windows/assemblies 目录,您会发现您有一个对 Oracle.DataAccess.dll (x2) 的引用,其中一个用于 x86,另一个用于 AMD64。

Now, depending on if you have developers or are developing on the machine yourself, you may be ok here, however, if they are using older drivers, then you need to perform one last step.

现在,取决于您是否有开发人员或正在自己的机器上开发,您在这里可能没问题,但是,如果他们使用较旧的驱动程序,那么您需要执行最后一步。

Navigate to the app\name\product\version\client_1\odp.net\publisher policy\2.x directory. Included in here are two policy files. use gacutil /i to install the Policy.2.111.Oracle.DataAccess.dll into the GAC. This will redirect legacy oracle ODP calls to the newer versions. So, if someone developed with the 10g client, it will now work with the 11 client.

导航到 app\name\product\version\client_1\odp.net\publisher policy\2.x 目录。此处包含两个策略文件。使用 gacutil /i 将 Policy.2.111.Oracle.DataAccess.dll 安装到 GAC 中。这会将旧版 oracle ODP 调用重定向到较新的版本。所以,如果有人用 10g 客户端开发,它现在可以和 11 客户端一起使用。

If you need further details, or need other questions answered like flipping 32 bit mode on or off on your .net assemblies, email me.

如果您需要更多详细信息,或者需要回答其他问题,例如在 .net 程序集上打开或关闭 32 位模式,请给我发电子邮件。

J Banks [email protected]

J 班克斯 [email protected]

Good luck.

祝你好运。

回答by rlee923

If you can't have 32 bit oracle client working and installed 64 bit, you will need to install the 64 bit client, and grab the oracle.dataaccess.dll file under odp.net from the oracle client installed folder. And you have to use this dll and exchange the reference to this file instead of using 32 bit dll.( which is what you probably have for the project/solution)

如果你不能让 32 位 oracle 客户端工作并安装 64 位,你需要安装 64 位客户端,并从 oracle 客户端安装文件夹中获取 odp.net 下的 oracle.dataaccess.dll 文件。并且您必须使用此 dll 并交换对此文件的引用,而不是使用 32 位 dll。(这可能是您的项目/解决方案所拥有的)

If you have different bit of oracle client it's not going to work. so you will get errors like that. Hope that helps.

如果您有不同的 oracle 客户端,它将无法正常工作。所以你会得到这样的错误。希望有帮助。

See illustration on Implementing Oracle.Web.dll, Oracle.DataAccess.dll 64-bit failed on Windows Server 2008 with IIS 7.5 32-bit disabled

请参见在禁用 IIS 7.5 32 位的 Windows Server 2008实现 Oracle.Web.dll、Oracle.DataAccess.dll 64 位失败的插图

回答by Tod Thomson

If you're using the 32-bit version of Oracle.DataAccess.dll then you need to do one of the following:

如果您使用的是 32 位版本的 Oracle.DataAccess.dll,则需要执行以下操作之一:

a) Deploy to a 32-bit server, or

a) 部署到 32 位服务器,或

b) Deploy to a 64-bit server with 'Enable 32-bit applications' set to 'true'.

b) 部署到 64 位服务器,并将“启用 32 位应用程序”设置为“真”。

If you're using the 64-bit version of Oracle.DataAccess.dll then you simply have to use a 64-bit server.

如果您使用的是 64 位版本的 Oracle.DataAccess.dll,那么您只需使用 64 位服务器。

The problem is caused by Oracle as the don't offer an AnyCPU version of Oracle.DataAccess.dll (probably because it has unmanaged/native portions)

该问题是由 Oracle 引起的,因为它不提供 Oracle.DataAccess.dll 的 AnyCPU 版本(可能是因为它具有非托管/本机部分)

回答by akil

If you do the following, everything works fine 1. Consistently set all your dlls to AnyCPU. 2. Make sure that the appropriate version of the dll is installed on the machine on which the executable will be run (i.e. 32 bit or 64 bit i.e. same as OS) 3. Ignore compiler warnings that the a 64/32 bit version is being used rather than an MSIL version

如果您执行以下操作,一切正常 1. 始终将所有 dll 设置为 AnyCPU。2. 确保在将运行可执行文件的机器上安装了适当版本的 dll(即 32 位或 64 位,即与操作系统相同) 3. 忽略 64/32 位版本正在运行的编译器警告使用而不是 MSIL 版本

The compiled versions can then be used on both 32 and 64 bit as long as the appropriate version of the oracle dll is installed.

只要安装了适当版本的 oracle dll,编译后的版本就可以在 32 位和 64 位上使用。