I'm using Visual C# Studio 10.0 with .NET Framework 4.0 and I was trying to load in the SoundTouchSharp library and create an instance of the library (object) in my application. However, after I type in the path for the file, I get this error:
BadImageFormatException
was unhandled -- An attempt was made to load a program with an incorrect format. (Exception fromHRESULT
: 0x8007000B)
How should I fix that? I'm almost positive that I created the .dll using the VS terminal and it should be the same version as the .NET framework. I can also provide more code if needed.
Thanks!
SOLUTION: If you are on IIS7, Right Click/ Advanced Settings on the Specific Application Pool of the website and select True on Enable 32-Bit Applications. It should work.
This exception is thrown when the file format of a dynamic link library (. dll file) or an executable (.exe file) doesn't conform to the format that the common language runtime expects.
“An attempt was made to load a program with an incorrect format.” That means that the assembly, which was to be loaded, was in an unexpected format. The format, in this case, refers most likely to the 64-bit build of an application being deployed to IIS, which is being run in 32-bits.
Make sure that you are not having 32-bit / 64-bit conflict.
Refer this question:
Troubleshooting BadImageFormatException
If you're running on a 64-bit OS, the Assembly RevitAPI may be compiled as 32-bit and your process as 64-bit or "Any CPU".
Or, the RevitAPI is compiled as 64-bit and your process is compiled as 32-bit or "Any CPU" and running on a 32-bit OS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With