Could not load file or assembly 'System.Web.Http.WebHost, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies

I have purchased the course: ”Sitecore® 8.2 Experience Solution Developer Course” but have an issues that prevents me from progressing. The error I see is this:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'System.Web.Http.WebHost, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error: 

Line 154:        <add assembly="System.Web.WebPages.Razor, Version=, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
Line 155:        <add assembly="System.Web.Http, Version=, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
Line 156:        <add assembly="System.Web.Http.WebHost, Version=, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
Line 157:        <add assembly="System.Net.Http.Formatting, Version=, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
Line 158:        <add assembly="System.Web.Http.Cors, Version=, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>

Source File: C:\inetpub\wwwroot\ssd.tac.local\Website\web.config    Line: 156 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Http.WebHost, Version=, 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].

It started to appear after I did the publishing on page 9 in the module 5 workbook where it says


"Deploy and preview your changes"

On the Visual Studio toolbar, deploy your code by clicking Web One Click Publish.


So far I had only been publishing a single file at a time because it kept failing (the files wasn’t published and the “waiting” symbol was shown forever)

I really hope you can help me out on this one. I have googled for answers and spend a lot of time on this. So far to no awail. :(

Please let me know if I can supply more info

  • Check you bin folder in the Sitecore webroot folder, Check the System.Web.Http.WebHost.dll. and look at the version.

    Looks like in your project you have a reference to another version of System.Web.Http.WebHost.dll than the version Sitecore use.
    if possible use the same version as your Sitecore use for all dll's

    So first check for Visual Studio solution on which NuGet you use and be sure you use the same version as Sitecore use.
    <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" ....

    Beside this dll, Sitecore use many Microsoft.* dll's , System.* and Newtonsoft.Json.dll
  • Jan is correct... This error is very common when the offending DLL that is in your "bin" folder is a different version than is specified in your web.config. Most of the time, this happens because the referenced NuGet DLL in your source code is a different version than what Sitecore shipped with and when you publish your solution, the mismatched DLL gets deployed to the "bin" folder. Alternatively, it could also be because the web.config file was modified with a version that is not what Sitecore shipped with. In any case, the correct resolution would be to use the DLL version that your Sitecore version initially comes with. Adjust either your web.config, or the NuGet package that you are referencing so that the DLL versions are matching.

  • In reply to Jan Bluemink:

    Thank you very much! This was indeed the problem and it turned out there were a lot more like this when the first reference got fixed.
  • In reply to Bhavik Patel:

    Thanks for the clarification. As I couldn't see clearly which package to update in NuGet I replaced the assemblys with the the ones from the course files.