Error: This assembly is built by a runtime newer than the currently loaded runtime

I have downloaded published (code behind files are no there, combined with dll in bin folder) web application from Window Server 2008 where it is hosted, and open it with Visual Studio when I debug that application it shows following error:

“Could not load assembly because this assembly is built by a runtime newer than the currently loaded runtime”

I don’t know how can I solve this problem and test application locally.
Please help me.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This errors happens when the DotNet framework you are using is of older version than the one used to build the assembly. You need to check which version of framework is used to build those assemblies and then use the same or higher to debug too.

Method 2

I was getting this same error when running an installer for a Windows service, even when running the installer on the PC the installer was built on.

It turned out that although the Windows service project had been updated to .NET 4.5, the Setup project that was making the installer was still set to use .NET 2.0.

To check if the Setup project is using an older version of .NET than the project to be installed, in the Visual Studio Solution Explorer:

  1. Expand the Setup project;
  2. Under the Setup project, expand Detected Dependencies;
  3. Under Detected Dependencies select Microsoft .NET Framework and check the Version property. Select the appropriate .NET version from the dropdown list;
  4. Re-build the Setup project to create a new version of the installer.

Method 3

This error can have a lot of other reasons, too. I had the same problem, and nothing helped until I stumbled across this:
TlbExp.exe error:This assembly is built by a runtime newer

Method 4

I just ran into this issue when the assembly was built with a target framework of .NET 4, and v4.0.30319 was installed on the server, and other 4.0 apps were running successfully.

The problem arose because the app had originally been built targeting 2.0, and new 4.0 assemblies were pushed, but not the app.config file, which we generally update separately.

This means the supportedRuntime attribute was not updated in the config and caused the error. Adding the following to the app.config fixed our issue:

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>

Method 5

One the the assemblies reference in the project might be built using a newer version of .net, check version of every assembly reference and correct accordingly.

Method 6

Also check the application pool that this web site is running as. It could be framework 2.0 default on some older windows servers. Change it to framework 4.0.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x