This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed

如果试了网上说的instantclient-basic-win-x86-64-11.1.0.7.0,还是无效的话,试试下面的。

本机:XP(32位)+Oracle10g(32位)

服务器:Windows Server 2008(64位)+Oracle11g(64位)+IIS

 开发调试过程中(项目属性any CPU),从本机访问服务器上的数据库正常。但是把程序部署到服务器后,程序无法访问服务器上的数据库,并报错“Attempt to load Oracle client libraries threw BadImageFormatException.  This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.


解决办法:在服务器上安装 Oracle Client(32位)的(本次安装的是10gClient 32位),重启电脑后,服务器上的程序正常访问数据库。

原因综合网上资料,个人理解为:因为服务器上的程序是以32位运行(w3wp.exe *32).访问Oracle数据库需要32位的oci.dll。但是服务器的oci.dll为64位,所以总是有上面的错误提示。当时手上只有32位的 oracle10g client ,报着试一试的心态装好后,重启电脑,访问成功。

装32位client的最终目的是把32位的oci.dll放到服务器上,并自动在系统环境变量里写上路径。刚验证了一下,把环境变量路径改了,重启,就又连不上了。


原文地址:https://www.cnblogs.com/76674718/p/2252789.html