This project is read-only.

Dependency on System.Web.Http.WebHost, Version=

Jan 2, 2015 at 5:57 PM
Happy New Year Max!

I have just started switching my MVC.NET apps to use the 4.5.1 framework now pre-installed on all our Windows Server 2012 R2 servers.

When trying to run the app against the new framework, it compiles but I immediately get an error that looks like a MVCodeRouting dependency to a specific version of System.Web.Http.WebHost. The version installed under 4.5.1 framework is 5.1

Server exception excerpt from Stack Trace:

[FileLoadException: 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)]
MvcCodeRouting.Web.Http.WebHost.PreApplicationStartCode.Start() in d:\foss\MvcCodeRouting\src\MvcCodeRouting.Web.Http.WebHost\PreApplicationStartCode.cs:40

How do I get around this?

Jan 2, 2015 at 6:13 PM
Nevermind Max - think I found a solution. Added the following to web.config file and no more complaints from the MvcCodeRouting infrastructure.
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="" newVersion="" />
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="" newVersion="" />
            <assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="" newVersion="" />
Marked as answer by maxtoroq on 1/2/2015 at 10:14 AM
Jan 2, 2015 at 6:15 PM
Yup, it's a version redirect issue. Happy New Year to you also :)