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?

5
  • 1
    check the app.config, do you have some entries like supportedRuntime or requiredRuntime? Commented Sep 6, 2011 at 20:22
  • Is this a Windows-Service? If so, have you tried to install it with the 64bit version of Installutil? Commented Sep 6, 2011 at 20:23
  • This is my config: <?xml version="1.0"?> <configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup> </configuration> Commented Sep 6, 2011 at 20:25
  • This usually happens when there is an x86/x64 issue. Commented Sep 6, 2011 at 20:33
  • 1
    I checked it - everything build for x86 platform Commented Sep 6, 2011 at 20:37

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

In the properties of the main executable project, i see that Target Framework is: .NET Framework 4.0
@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?
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)
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.