I'm running my application on an IIS server, but now I want to do some debugging with breakpoints etc, so I decided to run from Visual Studio to IIS Express. But, when I start running my application I receive this error:
Server Error in '/' Application.
Could not load file or assembly 'System.Web.Http.WebHost,
Version=5.2.3.0, 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)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.FileLoadException: Could not load file or
assembly 'System.Web.Http.WebHost, Version=5.2.3.0, 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 13:
Database.SetInitializer(new
TodoListServiceInitializer()); Line 14:
GlobalConfiguration.Configure(WebApiConfig.Register); Line 15:
} Line 16: } Line 17: }Source File:
C:\develop\spl_development\main\Docks\Docks_Sensor\Global.asax.cs
Line: 15Assembly Load Trace: The following information can be helpful to
determine why the assembly 'System.Web.Http.WebHost, Version=5.2.3.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.=== Pre-bind state information === LOG: DisplayName = System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Appbase =
file:///C:/develop/Spl_Development/Main/Docks/Docks_Sensor/ LOG:
Initial PrivatePath =
C:\develop\Spl_Development\Main\Docks\Docks_Sensor\bin Calling
assembly : Docks.Sensor, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null.
=== LOG: This bind starts in default load context. LOG: Using application configuration file:
C:\develop\Spl_Development\Main\Docks\Docks_Sensor\web.config LOG:
Using host configuration file:
C:\Users\ligthart\Documents\IISExpress\config\aspnet.config LOG: Using
machine configuration file from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Http.WebHost, Version=5.2.3.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: Attempting
download of new URL
file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary
ASP.NET Files/vs/25aafd2f/29cb2bd3/System.Web.Http.WebHost.DLL. LOG:
Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary
ASP.NET
Files/vs/25aafd2f/29cb2bd3/System.Web.Http.WebHost/System.Web.Http.WebHost.DLL.
LOG: Attempting download of new URL
file:///C:/develop/Spl_Development/Main/Docks/Docks_Sensor/bin/System.Web.Http.WebHost.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build
Number ERR: Failed to complete setup of assembly (hr = 0x80131040).
Probing terminated.Stack Trace:
[FileLoadException: Could not load file or assembly
'System.Web.Http.WebHost, Version=5.2.3.0, 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)]
Docks.Sensor.WebApiApplication.Application_Start() in
C:\develop\spl_development\main\Docks\Docks_Sensor\Global.asax.cs:15[HttpException (0x80004005): Could not load file or assembly
'System.Web.Http.WebHost, Version=5.2.3.0, 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)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +9966013
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) +352
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +296[HttpException (0x80004005): Could not load file or assembly
'System.Web.Http.WebHost, Version=5.2.3.0, 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)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +261Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.6.1055.0
I've seen a lot of questions, but can't really seem to find an answer to this problem. I went looking if any of the required files or references were missing.. but no:
References:
bin folder:
version:
I have tried to remove the bin folder, everything.. I just can't seem to get it working. I hope there's a solution, thanks in advance!
Best Answer
remove System.Web.Http.WebHost.dll and add with old version 4.0.0.0