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

后端 未结 21 2178
南方客
南方客 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 13:39

    I was also getting the same error I checked it my system was in 64 bit and I was using oracle.DataAccess of 32 bit version I added correct 64 version now it got resolved below path for the ref of Oracle.DataAccess.dll

    Correct path for 64 bit OS- C:\Oracle\11g_64\product\11.2.0\client_64\odp.net\bin\4\Oracle.DataAccess.dll

    Correct path for 32 bit OS- C:\Oracle\11g_32\product\11.2.0\client_64\odp.net\bin\4\Oracle.DataAccess.dll

    0 讨论(0)
  • 2020-11-21 13:47

    Make sure that registry HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ODP.NET\4.112.# DIIPath key is pointing to 32 bit Oarcle client BIN directory. For example, DIIPath value can be C:\app\User_name\11.2.0\client_32bit\bin

    0 讨论(0)
  • 2020-11-21 13:51

    BadImageFormatException occures when a 32bit (x86) dll calls a 64bit dll or vice versa. If using AnyCPU for your entry executable then when run on a 64bit machine it will run as 64bit, however if that then calls a 32bit dll you get the exception which is why AnyCPU isn't always the answer.

    I tend to build everything as 32bit (x86) as we still have to interface with some old components done in VB6 (32bit (x86)). While performance might be better for 64bit machines if we where to build in AnyCPU reliability is more important for us.

    I would suggest trying to build all you components in 32bit (x86), unless you are doing some really intensive stuff I doubt it will make much difference.

    0 讨论(0)
  • 2020-11-21 13:52

    As apc mentioned that error occurs "when a 32bit dll calls a 64bit dll or vice versa". The problem is that if you have build using AnyCPU and are running on a 64bit environment then the application will run as 64bit. If rebuilding explicitly for 32 and 64 bit is not an option then you could use a microsoft utility called corflags.exe which comes with the Windows SDK. Basically, you can modify a flag in the exe of the program you are executing to tell it to run as 32bit even if the environment is 64bit.

    See here for information on using it

    0 讨论(0)
  • 2020-11-21 13:52

    I had the same issue, then I fix it by change configuration manager x86 -> x64 and build

    image

    0 讨论(0)
  • 2020-11-21 13:54

    To revise IIS

    1. Select Application Pools.
    2. Clic in ASP .NET V4.0 Classic.
    3. Select Advanced Settings.
    4. In General, option Enable 32-Bit Applications, default is false. Select TRUE.
    5. Refresh and check site.

    Comment:

    Platform: Windows Server 2008 R2 Enterprise - 64Bit - IIS 7.5

    0 讨论(0)
提交回复
热议问题