尝试加载Oracle客户端库扔BadImageFormatException客户端、加载、Oracle、BadImageFormatException

2023-09-03 05:14:03 作者:歌满长安

在试图从.NET得到以下异常连接到Oracle数据库:

While trying to connect to oracle database from .net getting the following exception:

尝试加载Oracle客户端库扔BadImageFormatException。在64位模式安装了32位Oracle客户端组件运行时,会出现此问题。

在经历许多环节,我试图通过改变目标平台的任何CPU.Since克服这个例外是WPF应用程序,改变该平台的目标是抛出以下异常后:

After going through many links i tried to overcome this exception by changing the platform target to Any CPU.Since it is wpf application,after changing the platform target it is throwing the following exception:

SSC_GIP_UI.MainWindow在类型构造函数的调用'符合指定绑定约束引发了异常。行号'3'和线位9。

但它运行良好与目标平台的x86没有抛出上述异常,但它抛出 BadImageFormatException

But it runs fine with platform target x86 without throwing the above exception ,but it throws BadImageFormatException.

在这我工作的enironment是: Windows Server 2008中, .NET框架4.0, Oracle 11g数据库(64位)

The enironment on which i am working is: Windows server 2008, .net framework 4.0, oracle 11g (64-bit)

谁能告诉me.how解决?

can anyone tell me.how to fix it?

推荐答案

此错误表明你有32位和64位组件之间不匹配您的应用程序。

This error indicates that you have a mismatch between 32 bits and 64 bits components in your application.

当您在运行64位的Windows应用程序,它可以为无论是64位或32位模式运行。如果您已设置了目标平台为X86,它会作为32位运行。如果你已经确立了自己的平台的目标为64位或值为anycpu它将作为64位运行。

When you run an application in 64 bits Windows, it may run as either 64 bits or 32 bits. If you have set the platform target as x86, it will run as 32 bits. If you have set your platform target as x64 or AnyCpu it will run as 64 bits.

Oracle有不同版本中,它的客户端的,一个是32位,而另一个是64位。所以,如果您的应用程序在32位模式下运行,你需要确保你的32位安装了Oracle客户端。

Oracle has different versions of it's client, one is 32 bits and the other is 64 bits. So, if your application is running in 32 bits mode, you need to make sure your 32 bits Oracle client is installed.