We have an old project (WebApplication NET3.5) which hosts few SOAP WebServices and wanted to extend it to provide some REST services for mobile devices. To do that we installed the ASP WebApi by using the NuGet package provided here: http://www.nuget.org/packages/WebApi.All. Download and installation worked fine after the project build has been set to .NET 4.0.
Unfortunately after starting of application (‘F5’) and trying to navigate to any of REST operations (in MVC term ‘actions’) the request has failed with following error:
[FileLoadException: Could not load file or assembly 'System.Net.Http, Version=2.0.0.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.Lazy`1.get_Value() +12777347
System.Web.Http.WebHost.HttpControllerHandler.BeginProcessRequest(HttpContextBase httpContextBase, AsyncCallback callback, Object state) +256
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +405
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
The reason for this error is a mismatched project reference to System.Net.Http assembly. The project file references to public key b03f5f7f11d50a3a.
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.dll</HintPath>
</Reference>
However the installed version of System.Net.Http.Dll in NuGetPackage has new token 31bf3856ad364e35'
To workaround this open the project file and change the token as shown below:
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=
31bf3856ad364e35' , processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.dll</HintPath>
</Reference>
Posted
Apr 10 2012, 11:31 AM
by
Damir Dobric