Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I've upgraded a class library project in my solution to .NET Framework 4.0. But after the upgrade I figured out the server i'm using doesn't support .NET Framework 4.0.

So I had to downgrade again to v3.5. But after doing this, I cannot run my application anymore. When I run it, it compiles correctly, starts up the browser and then I get this error:

Could not load file or assembly 'Xxxxx_DLL' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

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


The webapplication using the assambly is set to .NET Framework 3.5 and the assambly itself is also set to .NET Framework 3.5. So this error should not be possible.

Do you guys have any suggestions?
Posted
Updated 8-Dec-22 23:58pm
v2

The problem is likely to be in one or more of the assemblies you are referencing as part of your application.

Go into your project in VS, open up the "References" branch, and make a note of all the references you are using. You can then highlight each one in turn and look at the "Runtime Version" property in the Properties pane. At least one will be greater than the 3.5 your app is expecting.
 
Share this answer
 
Turns out the updated DLL (v4) was still in the Bin directory under a different name. Forgot I renamed the projectname.
 
Share this answer
 
I faced the same issue after upgrading my code base from .Net 3.5 to 4.7.
The mistake I was doing was not upgrading the IIS Application Pool to 4.0 integrated to match the upgraded code.

So few things:-
1. Ensure your DLLs and Project are pointing to the same target runtime
2. Clean/Rebuild solution
3. Ensure APP Pool is according to the Project framework
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900