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

后端 未结 21 2207
南方客
南方客 2020-11-21 13:30

I am getting this error while on of my .Net application are trying to make a connection to oracle database.

The error says that This problem will

21条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 14:04

    One solution is to install both x86 (32-bit) and x64 Oracle Clients on your machine, then it does not matter on which architecture your application is running.

    Here an instruction to install x86 and x64 Oracle client on one machine:

    Assumptions: Oracle Home is called OraClient11g_home1, Client Version is 11gR2

    • Optionally remove any installed Oracle client (see How to uninstall / completely remove Oracle 11g (client)? if you face problems)

    • Download and install Oracle x86 Client, for example into C:\Oracle\11.2\Client_x86

    • Download and install Oracle x64 Client into different folder, for example to C:\Oracle\11.2\Client_x64

    • Open command line tool, go to folder %WINDIR%\System32, typically C:\Windows\System32 and create a symbolic link ora112 to folder C:\Oracle\11.2\Client_x64 (see commands section below)

    • Change to folder %WINDIR%\SysWOW64, typically C:\Windows\SysWOW64 and create a symbolic link ora112 to folder C:\Oracle\11.2\Client_x86, (see below)

    • Modify the PATH environment variable, replace all entries like C:\Oracle\11.2\Client_x86 and C:\Oracle\11.2\Client_x64 by C:\Windows\System32\ora112, respective their \bin subfolder. Note: C:\Windows\SysWOW64\ora112 must not be in PATH environment.

    • If needed set your ORACLE_HOME environment variable to C:\Windows\System32\ora112

    • Open your Registry Editor. Set Registry value HKLM\Software\ORACLE\KEY_OraClient11g_home1\ORACLE_HOME to C:\Windows\System32\ora112

    • Set Registry value HKLM\Software\Wow6432Node\ORACLE\KEY_OraClient11g_home1\ORACLE_HOME to C:\Windows\System32\ora112 (not C:\Windows\SysWOW64\ora112)

    • You are done! Now you can use x86 and x64 Oracle client seamless together, i.e. an x86 application will load the x86 libraries, an x64 application loads the x64 libraries without any further modification on your system.

    • Probably it is a wise option to set your TNS_ADMIN environment variable (resp. TNS_ADMIN entries in Registry) to a common location, for example TNS_ADMIN=C:\Oracle\Common\network.

    Commands to create symbolic links:

    cd C:\Windows\System32 mklink /d ora112 C:\Oracle\11.2\Client_x64 cd C:\Windows\SysWOW64 mklink /d ora112 C:\Oracle\11.2\Client_x86

    Notes:

    Both symbolic links must have the same name, e.g. ora112.

    Despite of their names folder C:\Windows\System32 contains the x64 libraries, whereas C:\Windows\SysWOW64 contains the x86 (32-bit) libraries. Don't be confused.

提交回复
热议问题