Badimageformatexception is thrown when you try to load the Oracle client library. This problem occurs when the 32-bit Oracle client component is installed in 64-Bit mode.
This exception occurs when a. NET application running on a 64-bit platform tries to call a DLL that does not support 64-bit execution. If the application is generated in the "any CPU" mode without a specific platform, it runs in the 64-Bit mode based on the operating system, which causes this problem. To solve this problem, you can compile the program on the x86 solution platform to enable the program to run in 32-Bit mode, or run the program on the wow64 subsystem of the 64-bit operating system, and allow the use of 32-bit DLL.
1. Right-click the solution to be run-right-click Properties, select generate-platform, and change to x86. (Both vs2008 and vs2010 are suitable for looking at the problem from another angle. Can we modify the startup project -- attribute -- Target Platform specified platform of VS solution? Change to x86