windows System.data.OracleClient 在七个 64 位操作系统上带有 32 位 oracle 客户端驱动程序

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

System.data.OracleClient with 32 bits oracle client driver on Seven 64 bits Operating system

.netwindowssystem.data.oracleclient

提问by Benoit Durtaut

I have a Web application migrating from asp.net 1.1 (VS 2003) to Asp.net 2 ( VS 2008). I have a problem to execute Oracle connexion on the new version . The dev environnement is 64 bits Seven. When generate application with all CPU , i have a probleme on System.Data.OracleClient, exception System.BadImageFormatException: Tentative de chargement d'un programme de format incorrect. (Exception de HRESULT : 0x8007000B). . I generate on x86 CPU and i have this error on start :

我有一个从 asp.net 1.1 (VS 2003) 迁移到 Asp.net 2 (VS 2008) 的 Web 应用程序。我在新版本上执行 Oracle connexion 时遇到问题。开发环境是 64 位 7。使用所有 CPU 生成应用程序时,我在 System.Data.OracleClient 上遇到问题,异常 System.BadImageFormatException:暂定充值 d'un 程序格式不正确。(HRESULT 异常:0x8007000B)。. 我在 x86 CPU 上生成,但在启动时出现此错误:

[BadImageFormatException: Impossible de charger le fichier ou l'assembly 'CpimWebApplication' ou une de ses dépendances. Tentative de chargement d'un programme de format incorrect.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190

[BadImageFormatException: 不可能从组装 'CpimWebApplication' 和 une de ses 依赖项中取出充电器。暂定 d'un program de 格式不正确。]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad (AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean for Introspection) +416
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190

Whats the problem ? The Oracle Client on machine is 32 bits version . I have read on web that it s not possible to utilise System.data.OracleClient with 32 bits oracle Client ? Instal 64 bits Oracle client is the solution ? TIA Regards

有什么问题 ?机器上的 Oracle Client 是 32 位版本。我在网上读到它不可能使用 System.data.OracleClient 和 32 位 oracle 客户端?安装 64 位 Oracle 客户端是解决方案吗?TIA 问候

回答by GTG

If you are running your application in 64 bits mode you cannot use the 32 bits Oracle driver.

如果您在 64 位模式下运行应用程序,则不能使用 32 位 Oracle 驱动程序。

You need to either install the 64 bits Oracle driver and run your application in 64 bits mode,

您需要安装 64 位 Oracle 驱动程序并在 64 位模式下运行您的应用程序,

or

或者

set the application to run in 32 bits mode. You can do that in IIS by choosing your application pool, go to Advanced settings and set "Enable 32-bit applications" to true.

将应用程序设置为以 32 位模式运行。您可以通过选择应用程序池在 IIS 中执行此操作,转到高级设置并将“启用 32 位应用程序”设置为 true。

回答by Nathan

GTG is right.

GTG是对的。

However, System.Data.OracleClient is deprecated. Microsoft is not supporting it anymore.

但是,不推荐使用 System.Data.OracleClient。微软不再支持它了。

So, I would recommend you using Oracle Data Provider for .Net: ODP.Net.

因此,我建议您使用 Oracle Data Provider for .Net:ODP.Net。

You can download it from:

您可以从以下网址下载:

Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (32-bit)Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64)

适用于 Microsoft Windows(32 位)的Oracle Database 11g 第 2 版客户端 (11.2.0.1.0) 适用于 Microsoft Windows (x64) 的 Oracle Database 11g 第 2 版客户端 (11.2.0.1.0)

For development(Win7 64-bit), use 32-bit flavor. I've tried 64-bit Oracle client with no success. For production(Wind2008R2 64-bit), use 64-bit flavor. Note that they must be the same version (11.2.1.0).

对于开发(Win7 64 位),请使用 32 位风格。我尝试过 64 位 Oracle 客户端,但没有成功。对于生产(Wind2008R2 64 位),请使用 64 位风味。请注意,它们必须是相同的版本 (11.2.1.0)。

Also, make sure you compile your app for "Any CPU", adding the reference to Oracle.DataAccess, setting "Specific version" to "True" and "Local copy" to "False". By doing this, when you deploy your app to production environment, it will look for the same version (11.2.1.0, 64-bit equivalent), from the GAC.

此外,请确保为“任何 CPU”编译应用程序,添加对 Oracle.DataAccess 的引用,将“特定版本”设置为“真”,将“本地副本”设置为“假”。通过这样做,当您将应用程序部署到生产环境时,它将从 GAC 寻找相同的版本(11.2.1.0,64 位等效版本)。