3

I'm trying to publish an ASP.NET MVC 4 Internet Application. After it's been published, I go ahead and click the link for my website and find this:

Server Error in '/' Application.

Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

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.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:

[FileNotFoundException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] ProyectoFinal.MvcApplication.Application_Start() in c:\Users\EAGUILARCO\Documents\Visual Studio 2012\Projects\ProyectoFinal\ProyectoFinal\Global.asax.cs:26

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9916613 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

What I've tried so far:

  • Modify the registry, failed. Also, I am not sure about whether this would solve my issue.
  • Set the 'System.Web.Http.WebHost Copy Local' Property to 'true'. That didn't solve the issue either.

Update: the version of the System.Web.Http.WebHost is 4.0.20710.0

Jester
  • 56,577
  • 4
  • 81
  • 125
Edd
  • 1,948
  • 4
  • 21
  • 29
  • You may be running into this: [Windows update caused MVC3 and MVC4 stop working](https://stackoverflow.com/questions/26393157/windows-update-caused-mvc3-and-mvc4-stop-working) – haxorjim Dec 09 '14 at 01:39
  • I don't think so; my OS is Win7, hence I didn't intall any Win 8.1 update. I'm running VS 2012 Pro on my school's lab. – Edd Dec 09 '14 at 01:45

1 Answers1

8

The issue seems to be with finding the deployed assembly in your bin folder.

Check the bin folder - it should contain System.Web.Http.WebHost dll.

If this dll is in this folder, check the version by right-clicking the file and then properties.

If it isn't 4.0.0.0, then you should deploy version 4.0.0.0 or try right clicking on the reference in your project and making sure the "Specific Version" property is set to false.

Robert Anderson
  • 1,246
  • 8
  • 11
  • On the properties the version appears as 4.0.0.0, however in the bin folder it appears as 4.0.20710.0 Also, I tried with setting the "Specific version" prop to false. Issue persists. – Edd Dec 09 '14 at 02:38
  • Is it the same error message with the same assembly name now? – Robert Anderson Dec 09 '14 at 02:40
  • Try it also with System.Web.Http as that is a different assembly and it is the one in the stack trace. – Robert Anderson Dec 09 '14 at 02:46
  • 1
    It worked! However, another exception of those was thrown: 'System.Net.Http.Formatting'. I repeated the same procedure: set copy local to true and specific version to false. It is working perfectly. Thanks! – Edd Dec 09 '14 at 06:08
  • @Robert Anderson what bin folder? – Danny Bullis Oct 06 '16 at 18:24