Questions tagged [badimageformatexception]

The exception that is thrown when the file image of a dynamic link library (DLL) or an executable program is invalid.

BadImageFormatException is thrown when the file format of a dynamic link library (.dll file) or an executable (.exe file) does not conform to the format that is expected by the common language runtime. In particular, the exception is thrown under the following conditions:

  • An earlier version of a .NET Framework utility, such as ILDasm.exe or installutil.exe, is used with an assembly that was developed with a later version of the .NET Framework.

  • An attempt is made to load an unmanaged dynamic link library or executable (such as a Windows system DLL) as if it were a .NET Framework assembly.

  • A DLL or executable is loaded as a 64-bit assembly, but it contains 32-bit features or resources. For example, it relies on COM interop or calls methods in a 32-bit dynamic link library.

  • Components have been created using different versions of the .NET Framework.

147 questions
541
votes
26 answers

"An attempt was made to load a program with an incorrect format" even when the platforms are the same

I'm calling functions from a 32-bit unmanaged DLL on a 64-bit system. What I get is: BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) At first, I had my projects set to…
David Brown
  • 35,411
  • 11
  • 83
  • 132
524
votes
31 answers

Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException)

I have two projects, ProjectA and ProjectB. ProjectB is a console application, which depends on ProjectA. Yesterday, everything was working fine, but suddenly today when I run ProjectB I get this: BadImageFormatException was unhandled: Could…
63
votes
9 answers

System.BadImageFormatException An attempt was made to load a program with an incorrect format

I'm writing a plug-in for another program that is based on a public .NET API. Typically these plugins are made by creating a class library DLL that references the API assembly. Then a command class is created by inheriting from a base command class…
Eric Anastas
  • 21,675
  • 38
  • 142
  • 236
47
votes
9 answers

The module was expected to contain an assembly manifest

I have a project in c# that uses c++ library and some dlls. When I run it it works great. The library is Awesomium, contains both c++ library and c# wrappers When I create reference to this project from my ASP.NET MVC 4 project I get the following…
Aviran Cohen
  • 5,581
  • 4
  • 48
  • 75
40
votes
12 answers

BadImageFormatException when loading 32 bit DLL, target is x86

I have a DLL (FreeType) which is certainly 32-bit (header: IMAGE_FILE_MACHINE_I386). I want to use it from C# code, using DllImport. Target of my application is x86, IntPtr.Size is 4, process is 32-bit. But I get BadImageFormatException (Exception…
Coder
  • 483
  • 1
  • 4
  • 7
20
votes
10 answers

System.BadImageFormatException caused by NUnit project

Good day everyone. I have been having the same problem all day at work and am struggling to find any new paths to go down. I am getting the following error when my solution builds on server. I have no problem running/debugging all tests in the…
Matt Canty
  • 2,395
  • 5
  • 35
  • 50
18
votes
4 answers

Run-time Exception System.BadImageFormatException

Please help, I've tried everything else I can think of to solve this problem. And before you respond please note: I have done everything I can from other questions on StackOverflow.com and else-ware on the web. Such as but not limited to: Changing…
Seth Eden
  • 1,142
  • 2
  • 20
  • 42
17
votes
3 answers

BadImageFormatException x64 Issue

I swear the more Microsoft "evolves" Visual Studio, the more ignorant the entire process becomes. I have a Windows Service with 3 class libraries in it. I went into the properties for each class library and set the platform target to x64. I did…
13
votes
3 answers

BadImageFormatException Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format

I am getting following runtime error, with my console application(VS2012) which refers to "dcasdk.dll". .Net Framework of the console app is 4.5, platform target is "Any CPU". Could not load file or assembly 'dcasdk, Version=1.0.1.0,…
SSQs
  • 269
  • 2
  • 3
  • 15
12
votes
2 answers

Could not load file or assembly... Windows Azure Website

I understand there is lots of these posts around and I've dealt with these on my own before with no problem except this time. It's because I can't get the debug information i need out of Windows Azure and hoping someone might be able to help me…
Steven Yates
  • 2,400
  • 3
  • 30
  • 58
10
votes
1 answer

Resharper Unit Test Runner failed to run tests (System.BadImageFormatException) in release

Using VS 10.0.40219.1, Resharper 8.2.1 I had switched over to a Release build and forgotten about it. Next time I tried to run any of the unit tests, I got the error "Resharper Unit Test Runner failed to run tests" System.BadImageFormatException:…
Tom Bogle
  • 464
  • 4
  • 18
9
votes
1 answer

AspNetCompiler - An attempt was made to load program with an incorrect format

I am building a 64bit only web application (AssemblyA) and referencing another application I have built which is also 64bit only (AssemblyB). When I add AssemblyB as a reference in AssemblyA, I get the following compilation error in Visual…
Steve
  • 9,335
  • 10
  • 49
  • 81
7
votes
3 answers

What does BadImageFormatException 0x80131124 (Index not found) mean?

My program is occasionally crashing with the following error message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: Index not found. (Exception from…
gap
  • 2,766
  • 2
  • 28
  • 37
7
votes
2 answers

System.BadImageFormatException on running ServiceStack examples.

I am trying to run ServiceStack Examples projects. When I run the web client I am getting the following error: {System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT:…
TheVillageIdiot
  • 40,053
  • 20
  • 133
  • 188
6
votes
2 answers

All unit tests throwing BadImageFormatException with Moq?

I'm currently in the process of increasing code coverage on our software products and have ran into an issue; all of my unit tests (when compiled using 'Any CPU') are failing due to throwing a 'BadImageFormatException'. This exception can be…
Novastorm
  • 1,439
  • 3
  • 26
  • 40
1
2 3
9 10