Could not load file or assembly 'System.Web.Helpers, error on IIS 8

could not load file or assembly dll
could not load file or assembly in c:windows application
could not load file or assembly or one of its dependencies an attempt was made
could not load file or assembly visual studio 2017
could not load file or assembly version=1.0.0.0 culture=neutral publickeytoken=null
could not load file or assembly powershell
could not load file or assembly or one of its dependencies. a strongly-named assembly is required
could not load file or assembly visual studio 2019

I have a MVC4 web application that works fine on Visual Studio 2012, using the local IIS Express Server. When I publish the application to an IIS 8 web server running on Windows 2012, the initial login page displays correctly. However, using remote debugging, I see that when I check the credentials using the following line:

if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))

I get the error shown in the figure below: (source: usf.edu)

Solution - Copy reference to local

  1. Right click on reference System.Web.Helpers and select Properties
  2. Change Copy Local to true.
  3. Build Solution

How to resolve “Could not load file or assembly … or one of its , When we use multiple versions of same assembly, it is more likely to encounter this runtime exception. It is easy to resolve provided that the new assembly  Could not load file or assembly xxxxxx, Version=x.x.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx or one of its dependencies. The system cannot find the file specified. The hosting environment of WAWS contains a standard installation of .Net framework 2.0 to .Net framework 4.5.

Sounds as though MVC has not been installed on the server.

Could not load file or assembly or one of its dependencies, Check if you are referencing an assembly which in turn referencing an old version of unity. For example let's say you have an assembly called  Could not load file or assembly ‘[assemblyname]’ or one of its dependencies. An attempt was made to load a program with an incorrect format. No fear, though, as this is usually easily fixed. In quite a few cases, it’s simply a mismatch between architectures and easily changed.

The System.Web.Helpers.dll is included in the official Nuget package Microsoft.AspNet.WebPages.

Install that and the references should be corrected, and the file should be copied to your bin folder.

Error : Could not load file or assembly or one of it's dependencies , Yeah!!! I found a solution for this terrible error First of all Thanks for every one who tried to help me Here's my solution Right Click on the  The error message “Could not load file or assembly” can be quite a common error in ASP.NET applications. This is because it can occur for a whole plethora of reasons and this in itself can make it a bit of a tricky problem to solve.

I was able to resolve this by downloading the Microsoft Web Platform Installer, searching for MVC and installing the "ASP.NET MVC3 (Visual Studio 2010 ) Released 4/11/2011" package. Close any Visual Studio instance prior to installing.

Fixing the "Could not load file or assembly or one of its , This post describes how to fix the “Could not load file or assembly '[​assemblyname]' or one of its dependencies. An attempt was made to load a  In most cases .NET manages to solve the DLL hell problem pretty well, but sometimes it all falls apart, and when it does in best case scenario we see something like this: Could not load file or assembly 'XXXX, Version=X.Y.Z.W, Culture=neutral, PublicKeyToken=eb42632606e9261f' or one of its dependencies.

Make sure it's looking for the correct version of the file. Mine were incorrect, the web.config file was pointing to later versions than what I had in the project.

In the properties I noted the version was 2.0.0.0 so I made it this version in the web.config file

Could not load file or assembly 'xxx' or one of its dependencies error , The system could not find the 'Episerver.Forms.Core' assembly file to load. There are some workarounds for this issue: The dll file may not be in  Additional information: Could not load file or assembly 'Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

[Solved] Could not load file or assembly (dll file), So it works if I change in the c# project from Any CPU to x86(all dlls are compiled in WIN32) from Properties -> Build -> Platform Target. Re: Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0. Jan 15, 2020 10:16 AM. It means that the DLL 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0' is not in the Bin folder with the other DLL (s) the program is using. I suggest that you use Nuget, browse for the named DLL and install it in the project

"Could not load file or assembly" error when you compile a SDK , Could not load file or assembly 'file:///C:/Windows/assembly/GAC_32/Interop.SAF​/8.0.0.0__31bf3856ad364e35/Interop.SAF.dll' or one of its  Invoke-Sqlcmd : Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

'Could not load file or assembly' error, What could be the problem and how can we fix it? Thanks. Regards. Server Error in '/esprit' Application. Could not load file or assembly 'Microsoft 

Comments
  • Thanks for the response. I did read other responses mentioning that and I should have mentioned that. But I do not see System.Web.Helpers in the project references. WebMatrix.WebData is copied locally.
  • In my case "Copy Local" was already true. But for some reason (maybe because there were changes made related to nuget in the solution) the bin folder of solution on iis was not containing any .dll's including the System.Web.Helpers. When I Copied all the .dll's in that folder it started working. This may not be a solution but in case anyone faces this issue, First check whether .dll's are getting loaded in bin folder after building solution or not
  • Brilliant, I had a problem with Azure Webjobs and this was the error, finally this solution worked for me
  • Indeed, the standalone asp.net mvc 4 installer did it for me: microsoft.com/en-us/download/details.aspx?id=30683
  • I copied my project to a new system (Windows 10, Visual Studio 2015) and got this error. This fixed it for me.
  • This approach worked for me as well on my build server. I installed ASP.NET MVC 4 using the Web Platform Installer as the reference error went away.
  • This worked for me to resolve this reference in VS2015.
  • This worked for me to resolve this reference is VS2017.
  • Already had this installed and still getting this Reference error at Build time: warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
  • Maybe is not an answer. You should use comments for that. And of course welcome to the StackOverflow! :)