. Advertisement .
..3..
. Advertisement .
..4..
I get the “an attempt was made to load a program with an incorrect format” issue when trying to call functions from a 32-bit unmanaged DLL on a 64-bit system. Here is the detail of the error I got the error message:
BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Please give me some advice to solve this problem.
The cause:
After researching your error I found that by some way, your executable’s Build checkbox had been left unchecked in the Configuration Manager, so it was still using the old Any CPU build. This is the main reason of your error. In addition, I found out that there is another reason. Between the applications you are using, there is a 32 bit/64 bit mismatch.
Solution:
Right-click your project in Visual Studio -> Click the Build tab in the left pane.
Then choose x86 under the Platform Target (or more broadly, the architecture is suitable with the library to which you’re linking).
Another way is:
Open: Tools -> Options -> Projects and Solutions -> Web Projects -> Use the IIS Express’s 64 bit version.
If you follow my suggestions above, your error will be solved effectively.
The same error will occur if you attempt to run 32-bit apps on IIS 7 (or 64-bit OS machine). You can resolve this error by going to IIS 7 and clicking on the application pool. Then, click on “Advanced Settings” and change the “Enable 32 Bit Applications” setting to “TRUE”.
It should now work if you restart your website.