部署使用 Oracle.DataAccess 的 Web 服务器会导致各种程序集错误

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

Deploying web server that uses Oracle.DataAccess results in various assembly errors

.netwcforacleodp.net

提问by user55904

My development machine is Vista x64.

我的开发机器是 Vista x64。

I am using WCF web services to build web services interfacing to an oracle 10g database.

我正在使用 WCF Web 服务来构建连接到 oracle 10g 数据库的 Web 服务。

When development started, I could not use VS2008's built-in WCF test tool [WCFTestClient] that launches when you press F5 [Go], on the 32-bit Oracle.DataAccess.dll, because I get System.BadImageFormatException on the Oracle object. So in my development environment I switched to the ODP.NET 64 bit version for my referenced assembly, and that works great.

开发开始时,我无法在 32 位 Oracle.DataAccess.dll 上使用 VS2008 的内置 WCF 测试工具 [WCFTestClient],该工具在您按 F5 [Go] 时启动,因为我在 Oracle 对象上得到 System.BadImageFormatException。因此,在我的开发环境中,我为引用的程序集切换到 ODP.NET 64 位版本,效果很好。

I can deploy to my local IIS [7], but only if I use the 32bit Oracle.DataAccess.dll.

我可以部署到我的本地 IIS [7],但前提是我使用 32 位 Oracle.DataAccess.dll。

I am trying to deploy to a Win2003 [IIS 6] that has .NET 3.5 sp1 installed, and Oracle 10g database installed. Other web applications on this server successfully use oracle connections.

我正在尝试部署到安装了 .NET 3.5 sp1 和 Oracle 10g 数据库的 Win2003 [IIS 6]。此服务器上的其他 Web 应用程序成功使用了 oracle 连接。

If I remove all references to Oracle.DataAccess from the web.config file , and make sure there is no Oracle.DataAccess.dll in my bin/ folder, I can bring up the default service metadata page[s], but calling the service via a SOAP client results in an error:

如果我从 web.config 文件中删除对 Oracle.DataAccess 的所有引用,并确保我的 bin/ 文件夹中没有 Oracle.DataAccess.dll,我可以调出默认的服务元数据页面 [s],但调用该服务通过 SOAP 客户端导致错误:

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

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

However, if I put a copy of Oracle.DataAccess.dll in my bin/ folder, I get:

但是,如果我将 Oracle.DataAccess.dll 的副本放在 bin/ 文件夹中,则会得到:

"Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

“无法加载文件或程序集‘Oracle.DataAccess’或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)”

when trying to load the .svc page in a web browser.

尝试在 Web 浏览器中加载 .svc 页面时。

If I add an assembly reference to my web.config, I get a configuration error: "Could not load file or assembly xxx"

如果我向 web.config 添加程序集引用,则会收到配置错误:“无法加载文件或程序集 xxx”

I guess I'm looking for help understanding the assembly cache, and someone who has experience with ODP.net who can help me navigate this treacherous territory and get this service successfully deployed.

我想我正在寻找帮助理解程序集缓存,以及有 ODP.net 经验的人可以帮助我在这个危险的领域中导航并成功部署此服务。

回答by Brad

Recently I experienced a similar issue and found that the System.BadImageFormatException was caused by referencing the 32 bit version of Oracle.DataAccess from a project that specified a target platform of Any/x64. After setting the project to target x86 and configuration IIS 7 to enable 32 bit applications (right-click on the Application Pool -> Advanced Settings... set "Enable 32-bit Applications" set to true) everything seems to be working as expected. Also, hereis a link to an article explaining how to get both 32 and 64 bit versions running on different worker processes and another hereexplaining how to get 32 bit apps to run on 64 bit using IIS 6.

最近遇到了类似的问题,发现 System.BadImageFormatException 是由于从指定目标平台为 Any/x64 的项目中引用了 32 位版本的 Oracle.DataAccess 引起的。在将项目设置为面向 x86 并配置 IIS 7 以启用 32 位应用程序(右键单击应用程序池 -> 高级设置...将“启用 32 位应用程序”设置为 true)后,一切似乎都按预期工作. 此外,这里是一个文章的链接解释如何获得32个和64位版本在不同的工作进程运行,另一个在这里解释如何让32个应用程序使用IIS 6在64位上运行。

回答by user55904

Ok I've managed to [partially] resolve it, but I still need to know WHY this caused the error.

好的,我已经设法[部分]解决了它,但我仍然需要知道为什么这会导致错误。

I installed ODP.NET 32 bit on my local machine, in a separate folder from the 64 bit installation. I changed the assembly reference in my VS project to the Oracle.DataAccess.dll located in odp.net/bin/2.x/ folder.

我在本地计算机上安装了 ODP.NET 32 位,位于与 64 位安装不同的文件夹中。我将 VS 项目中的程序集引用更改为位于 odp.net/bin/2.x/ 文件夹中的 Oracle.DataAccess.dll。

Now the SOAP message doesn't throw an error anymore.

现在 SOAP 消息不再抛出错误。

The question now becomes: why is my choice of dll in my development environment driving the dll that must be used in the production environment? I want to be able to develop on 64 bit and deploy to a 32bit server without having to change my references every time i want to deploy.

现在的问题变成了:为什么我在开发环境中选择的dll驱动了必须在生产环境中使用的dll?我希望能够在 64 位上进行开发并部署到 32 位服务器,而不必在每次部署时更改我的引用。

回答by Chris Case

My company's run into the same problem, and we've had to settle on using the 32bit dll for lack of a better solution.

我的公司遇到了同样的问题,由于缺乏更好的解决方案,我们不得不决定使用 32 位 dll。

From what we've been able to tell, Oracle's 64bit dlls are built exclusively for 64bit. Unlike a dll build with "Any", it doesn't include the 32bit object code as well. That would be fine, except for the additional problem that the 32bit dll seems to fail to load at allunless the project is built exclusively for 32bit.

据我们所知,Oracle 的 64 位 dll 专为 64 位构建。与使用“Any”构建的 dll 不同,它也不包含 32 位目标代码。这很好,除了 32 位 dll 似乎根本无法加载的附加问题,除非该项目专为 32 位构建。

We've tried dozens of iterations of 64/32bit dll and project settings, and we have been completely unable to get anything to work except 32bit dll/32bit project. In the end we had to move forward with the project and stop investing time into what seemed like a endless struggle.

我们已经尝试了 64/32 位 dll 和项​​目设置的数十次迭代,除了 32 位 dll/32 位项目之外,我们完全无法获得任何工作。最后,我们不得不继续推进项目,停止将时间投入到看似无休止的斗争中。

My honest suggestion would be to evaluate alternative database solutions, if possible. My experience with Oracle has been verypainful.

如果可能的话,我诚实的建议是评估替代数据库解决方案。我在 Oracle 方面的经历非常痛苦。

Otherwise, simply build in 32bit. It shouldn't cause any issues.

否则,只需在 32 位中构建。它不应该引起任何问题。