Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 376
Arun Rana Avatar asked Feb 28 '11 06:02

Arun Rana


4 Answers

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.

like image 151
Sachin Shanbhag Avatar answered Nov 19 '22 13:11

Sachin Shanbhag


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.

like image 27
Simon Tewsi Avatar answered Nov 19 '22 12:11

Simon Tewsi


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

like image 2
peregrin Avatar answered Nov 19 '22 12:11

peregrin


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>

like image 2
Danny Avatar answered Nov 19 '22 13:11

Danny