简体   繁体   中英

System.BadImageFormatException was unhandled - simple fix

Here is a short video of my error.

It is obvious that I have something wrong between 32-bit and 64-bit. However I cant find anything that holds my hand enough to walk through the solution in Visual Studio 2012.

Can anyone give me a more detailed explanation of what and how to change in my settings?

The "startup project" (the one that builds the .exe file) determines whether the process will run 32 or 64 bits. Any library that is referenced must support the same "bitness".

If you use libraries that requires a specific CPU type, you should change the "Target CPU" property in the "Build" tab of the project properties of the project that creates the main executable to that CPU type.

Any managed library that you use, that does not depend on cpu-specific libraries can be compiled as "Any CPU".

I don't know the library you're using, but this link makes me think it requires a 32 bit build.

EDIT: I just realized I only know earlier versions of Visual Studio, so the option may be located elsewhere in 2012.

I've dealt with a similar issue just a few days ago. It wasn't as straightforward as one would expect (given the error), I had to use dependency walker in order to check if all needed dependencies of my dlls were in the correct format, turned out my dll was importing an incorrect dependency.

Dependency Walker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM