在Windows 2008 R2 64位操作系统上运行Oracle和WCF

4

我正在尝试将一个连接到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'

我尝试了很多方法,但似乎没有什么效果。由于我很急于让它工作,所以去使用了被标记为废弃的OracleClient,只是为了让它工作并给我时间。我卸载了所有已安装的内容,只安装了带有运行时选项的win64_11gR2_client.zip。然而,之后我开始遇到以下问题:

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

我重新安装了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

如果我尝试更改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.

我迷失了方向,不知该如何是好。为什么设置“简单”的Oracle安装会这么难?我要解决什么问题?有没有人知道一篇博客文章可以展示如何正确设置它?我试着找了,但找不到任何东西,我相信我不是唯一有这个问题的人。
嗯,任何帮助都将不胜感激。非常感谢。
编辑
我回来尝试使用ODP.NET,因为在尝试使用Microsoft的OracleClient时出现了所有问题。我在开发机上安装了OPD.NET2 64位,在项目的参考文献中,我删除了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

这可能是因为它试图加载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 ---
3个回答

8

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
我在我的开发机上遇到了同样的问题。我检查了IIS上应用程序池的设置,发现"启用32位应用程序"选项已经被设置为"True"。由于我只使用64位应用程序,因此将此选项设置为其默认值"False"对我来说是安全的。之后一切都正常了。
您可以在IIS 7管理器中更改此设置。右键单击应用程序池,选择"高级设置..."。它在"(常规)"组中。

问题在于,如果在 AppFabric 中使用 IIS/WAS(例如 net.tcp 绑定),则会遇到一个丑陋的错误,导致整个应用程序池崩溃,因此无法正常工作。如果仅使用 HTTP,则可以正常工作。 - Pascal
感谢您关于“启用32位应用程序”的提示。由于某种未知原因,该位被设置为false,因此在我的64位开发环境中使用32位Oracle库运行项目时,我遇到了“BadImageFormatException”错误。 - chris

3

好的,我能够使用Oracle ODP.Net使其正常工作。只需按照以下步骤进行:

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

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

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

  • 应该可以正常工作了。

感谢@rlee923的帮助!


2

您是否已经下载并安装了客户端的64位版本?

看起来数据访问Oracle DLL文件是32位的。

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


我在服务器上安装了64位版本。有没有任何明确的解释,告诉我需要做什么来修复这个问题? - Pascal
你是否已经获取了oracle.dataaccess.dll文件并将其添加到你的解决方案/项目引用中? - rlee923
对不起,我很无知,请问是哪个版本?32位还是64位?v2还是v4?我安装在我的Windows 7上的应该是32位的,对吧?如果我需要引用64位的,我需要安装吗?那不会影响我的当前配置吗? - Pascal
我确定Win2k8 R2只有64位。如果您正在使用Win7,则可以通过按Win键+ Break键来检查它。 - rlee923
不论是 v2 还是 v4,只要是 64 位的都可以。 如果您不确定,请使用最新版本。 是的,您需要安装它。 - rlee923
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接