在 Windows 2008 R2 64 位和 WCF 上运行 Oracle

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

Running Oracle on Windows 2008 R2 64-bits and WCF

wcforacleiis-764-bitwindows-server-2008

提问by Pascal

I'm trying to deploy to a Windows 2008 R2 64-Bits server running AppFabric a WCF 4.0 service that connects to an Oracle 10gR2 database. On my Windows 7 64-Bits, inside Visual Studio 2010, everything goes well. I first started using Oracle ODP.NET and, on deploy, I started getting the:

我正在尝试将连接到 Oracle 10gR2 数据库的 WCF 4.0 服务部署到运行 AppFabric 的 Windows 2008 R2 64 位服务器。在我的 Windows 7 64 位上,在 Visual Studio 2010 中,一切顺利。我首先开始使用 Oracle ODP.NET,在部署时,我开始获得:

System.IO.FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
File name: 'Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342'

I tried so many things, and nothing seemed to work, and since I'm kinna desperate to get this working, and went to OracleClient, despite the fact that it's marked as deprecated, just to get this working, and buy me time. I removed everything I had installed, but installed just the win64_11gR2_client.zip, with the runtime option. However, than I started getting:

我尝试了很多东西,但似乎没有任何效果,因为我非常渴望让它工作,所以我去了 OracleClient,尽管它被标记为已弃用,只是为了让它工作,并为我争取时间。我删除了我安装的所有东西,但只安装了带有运行时选项的 win64_11gR2_client.zip。然而,比我开始得到:

System.DllNotFoundException: Unable to load DLL 'oramts.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

So I reinstalled the win64_11gR2_client.zip, adding the Oracle Services for Microsoft Transaction Server component. But then, whenever I made a call to my WCF service, IIS would crash with the error below:

所以我重新安装了 win64_11gR2_client.zip,添加了 Oracle Services for Microsoft Transaction Server 组件。但是,每当我调用 WCF 服务时,IIS 都会崩溃并显示以下错误:

Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2
Faulting module name: ntdll.dll, version: 6.1.7601.17514, time stamp: 0x4ce7c8f9
Exception code: 0xc0000374
Fault offset: 0x00000000000c40f2
Faulting process id: 0xb28
Faulting application start time: 0x01cc0b141a857fac
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 7630c4b0-7707-11e0-8419-00155d010609

If I tried to change the AppPool to enable 32-bits application, the WSDL doesn't even get generated, and I get the:

如果我尝试更改 AppPool 以启用 32 位应用程序,WSDL 甚至不会生成,我得到:

A process serving application pool 'MyAppPool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '2856'. The data field contains the error number.

I'm lost, and I don't know what to do. How can it be this hard to do a "simple" and typical Oracle set up? What problem would I try to solve? Does anyone know of a blog post that would show how to correctly set this up? I tried looking, but coudln't find anything, and I'm sure I'm not the only one with this problem
Well, any help would be really appreciated. Tks so much

我迷路了,我不知道该怎么办。做一个“简单”和典型的 Oracle 设置怎么会这么难?我会尝试解决什么问题?有谁知道一篇博客文章会展示如何正确设置它?我尝试寻找,但没有找到任何东西,而且我确信我不是唯一
遇到此问题的人,非常感谢任何帮助。太棒了

EDIT

编辑

I'm back trying to use the ODP.NET, since of all the problems that came up trying to use Microsoft's OracleClient. I installed OPD.NET2 64 bit on my development machine, on the project's Reference, I removed the 32-bit reference, and manually reference the 64-bits Oracle.DataAccess.dll. Whenever I do this, I'm unable to use the solution on my Dev Machine, since I get the error:

我回来尝试使用 ODP.NET,因为在尝试使用 Microsoft 的 OracleClient 时出现了所有问题。我在我的开发机器上安装了 OPD.NET2 64 位,在项目的 Reference 上,我删除了 32 位引用,并手动引用了 64 位 Oracle.DataAccess.dll。每当我这样做时,我都无法在我的开发机器上使用该解决方案,因为我收到错误:

Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format

This is probably due to the fact that it tries to load the 32-bit ODAC, instead of the 64-bit one. But, after I deploy to my 64-bit server, I stop getting the FileNotFoundException, but I start getting:

这可能是因为它尝试加载 32 位 ODAC,而不是 64 位 ODAC。但是,在部署到 64 位服务器后,我不再收到 FileNotFoundException,但我开始收到:

System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client
   at Oracle.DataAccess.Client.OracleInit.Initialize()
   at Oracle.DataAccess.Client.OracleConnection..cctor()
   --- End of inner exception stack trace ---

采纳答案by Pascal

Ok, I was able to get it working using the Oracle ODP.Net. Just take the following steps:

好的,我能够使用 Oracle ODP.Net 让它工作。只需执行以下步骤:

  • On the Dev machine, install Oracle's latest ODAC 64bits XCOPY, using something like install.bat all c:\oracle\64 oracle_home
  • On Visual Studio 2010, on the References, remove the Oracle.DataAccess reference that's default, since it's 32-bits. Go to browse, and inside the ODAC's 64 bits installation, you'll find \odp.net\bin\2.x\Oracle.DataAccess.dll. Reference this one
  • Rebuild your solution
  • Since I'm using WCF/IIS/AppFabric, I select Build Deployment Package
  • On the W2k8 R2 64 bits, install the same Oracle ODAC 64 bits ODAC used on the Dev machine
  • Reset IIS
  • To avoid TNS issues, since the full client won't be installed, use the connection string:

    Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SERVERHOSTNAME)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCLSID)));User Id=user;Password=blablabla;

  • Install the deployment package on IIS/AppFabric as you normally would.

  • Should work out fine
  • 在开发机器上,安装 Oracle 最新的 ODAC 64 位 XCOPY,使用类似 install.bat all c:\oracle\64 oracle_home
  • 在 Visual Studio 2010 的 References 上,删除默认的 Oracle.DataAccess 引用,因为它是 32 位的。转到浏览器,在 ODAC 的 64 位安装中,您将找到 \odp.net\bin\2.x\Oracle.DataAccess.dll。参考这个
  • 重建您的解决方案
  • 由于我使用的是 WCF/IIS/AppFabric,我选择了 Build Deployment Package
  • 在 W2k8 R2 64 位上,安装与 Dev 机器上使用的相同的 Oracle ODAC 64 位 ODAC
  • 重置 IIS
  • 为了避免 TNS 问题,由于不会安装完整的客户端,请使用连接字符串:

    数据源=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SERVERHOSTNAME)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCLSID)));User Id=user;Password=blablabla;

  • 像往常一样在 IIS/AppFabric 上安装部署包。

  • 应该工作得很好

Tks @rlee923 for your help!

Tks @rlee923 为您提供帮助!

回答by foka

I removed the 32-bit reference, and manually reference the 64-bits Oracle.DataAccess.dll. Whenever I do this, I'm unable to use the solution on my Dev Machine, since I get the error:

Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format

我删除了 32 位引用,并手动引用了 64 位 Oracle.DataAccess.dll。每当我这样做时,我都无法在我的开发机器上使用该解决方案,因为我收到错误:

Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format

I had the same issue on my dev-machine. I checked application pool's settings on IIS and it turned out that "Enable 32-Bit Applications"option had been set to "True". I work on 64-bit applications only, so it was safe for me to set this option to its default value: "False". After that all works fine for me.

我在我的开发机器上遇到了同样的问题。我检查了 IIS 上的应用程序池设置,结果发现“启用 32 位应用程序”选项已设置为“真”。我只在 64 位应用程序上工作,所以我可以安全地将此选项设置为其默认值:“False”。在那之后,一切对我来说都很好。

You can change this setting in IIS 7 Manager. Right click on the application pool and select "Advanced Settings...". It's in "(General)" group.

您可以在 IIS 7 管理器中更改此设置。右键单击应用程序池并选择“高级设置...”。它在“(一般)”组中。

回答by rlee923

did u download and install 64 bit version of the client?

你下载并安装了 64 位版本的客户端吗?

it seems like dataaccess oracle dll file is 32bit.

好像 dataaccess oracle dll 文件是 32 位的。

if you haven't I am not sure if there is still a problem with installing 64bit version of the client with R2, but you might have to modify the xml file of the installer to work.

如果没有,我不确定使用 R2 安装 64 位版本的客户端是否仍然存在问题,但您可能需要修改安装程序的 xml 文件才能工作。