4

I receive the following error:

Cannot load assembly. Error details: System.BadImageFormatException: Could not load file or assembly 'file:...' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

This assembly is built with .Net Framework 4.0 and i made sure that all projects in my solution are also built with .Net Framework 4.0.

Any idea why i am getting the error? How can i check which frameworks are loaded with my application?

Erik Sapir
  • 23,209
  • 28
  • 81
  • 141

2 Answers2

3

What is the main executable, i.e. the assembly responsible for deciding which version of the CLR is loaded? Note that it's not just a case of being built by .NET 4 - if your executable targets .NET 3.5 or lower, it will load in the .NET 2.0 CLR, and your .NET 4 assemblies won't load.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • In the properties of the main executable project, i see that Target Framework is: .NET Framework 4.0 – Erik Sapir Sep 06 '11 at 20:24
  • 1
    @Erik: Can you tell us more about the application? What sort of app is it? Do you have anything in the app.config about supportedRuntime? – Jon Skeet Sep 06 '11 at 20:25
  • I posted the content of the config in the comments of the question. The application is console application. It loads some DLL's from other project (all built with .NET Framework 4.0 - checked) – Erik Sapir Sep 06 '11 at 20:26
0

Hello I Had the same problem until i follow these hints: BadImageFormatException Class (section "Remarks")

In my case I was trying to load assemblies with call to umnaged code.

Bruno
  • 1,944
  • 13
  • 22