Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong version of System.Net.Http on build server

I came across this article yesterday because I wanted to implement attribute routing in my MVC project.

http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2

So I went and updated as per the message from the author in the comments.

Update-Package Microsoft.AspNet.WebApi.WebHost -Pre

Everything is working fine on locally but it won't build on the server. The error is as follows.

c:\BuildAgent\work\f8d76a59973cd8a9\Packages\Microsoft.AspNet.WebApi.Core.5.0.0-beta2\lib\net45\System.Web.Http.dll : error CS1705: Assembly 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\BuildAgent\work\f8d76a59973cd8a9\Aggregator\Spin.TradingServices.Aggregator.Web\Spin.TradingServices.Aggregator.Web.csproj]

I kind of understand what's going on and found a few things to do with other peoples questions on here, but none of them seem to work. I'd rather find a solution which only requires changes to the project and not the server.

So far I have:

  1. Set copy local to true, for System.Net.Http

  2. Set up binding redirect.

    <assemblyIdentity name="System.Net.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
    

Thanks, hope someone can help.

like image 538
Matt Canty Avatar asked Nov 02 '22 18:11

Matt Canty


1 Answers

It is now fixed. I have done the following things -

1 - Specify the version in the assemblies.

<system.web>
  <compilation debug="true" targetFramework="4.5">
    <assemblies>
      <add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </assemblies>
  </compilation>

2 - Set 'copy local' to true for System.Net.Http

3 - Copy the System.Net.Http.dll v4 into the project directory - thanks Aevitas.

Very sorry if this does not help anyone with seemingly the same issue. I had to made a lot of little changes and may not have remembered them all.

Thanks

like image 129
Matt Canty Avatar answered Nov 15 '22 04:11

Matt Canty