Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly ':This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

I Hvea 3 projects in my solution: BL, DL and the UI. All three projectshave a target framework of >NET 4; I have double-checked this by looking at the property page for each project. I am receiving the following error message when I try run the website at the hosting environment but not when I run it locally.

Could not load file or assembly 'BL' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Thanks in advance!

like image 466
Susan Avatar asked Aug 26 '12 16:08

Susan


People also ask

How do you fix Could not load file or assembly or one of its dependencies?

There are some workarounds for this issue: The dll file may not be in /bin folder. Just copy the dll file to /bin folder or set this preference Copy Local = True from Visual Studio. If the problem persists, check if the version of the assembly that is referenced is different than the version it is looking for.

Could not load file or assembly from assembly?

In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.


2 Answers

-Go to IIS. -Default WebSite-> Your application Directory->Advance Settings->Application Pool-> Set your Version (Ex. ASP.NET v4.0) -Refresh your Application Directory and Browse it. It's done.

like image 86
user2721039 Avatar answered Oct 19 '22 17:10

user2721039


You have to update your webservice extension to allow framework 4.0 in IIS. To enable the Web service extension for ASP.NET 4.0:

  1. Click Start, click Control Panel, click System Security, click Administrative Tools, and then click Internet Information Services (IIS) Manager.
  2. If you need to connect to a remote IIS Server, right click the Internet Information Services node and click the Connect... option.
  3. Type in the computer name for the remote IIS Server and credentials if necessary.
  4. Click the Web Service Extensions folder. The security lockdown console appears in the frame on the right.
  5. In the Web Service Extensions window, right-click the ASP.NET v4.X.XXXX, and then click Allow.
like image 29
Hassan Boutougha Avatar answered Oct 19 '22 18:10

Hassan Boutougha