System.Web.Http reference defaults to 4.0 version no matter how I try
Asked Answered
B

3

10

I am using the BreezeApi NuGet package in my project. It is in Visual Studio 2013.

I get this error.

Error 41 Assembly 'Breeze.WebApi2, Version=1.4.0.0, Culture=neutral, PublicKeyToken=f6085f1a45e2ac59' uses 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

I don't know why my project keeps referencing the 4.0 version. Things I tried:

  1. I removed the reference of system.web.http 4.0 from my project and browsed to the 5.0 DLL file location. As soon as I add it and come back to Solution Explorer, right click on the system.web.http dll, it is showing 4.0.0.0.

  2. I added assembly binding in web.config like below

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

How do I resolve this?

Bratcher answered 13/2, 2014 at 20:11 Comment(1)
What version of the framework are you targeting? Also, if you expand References, click on System.Web.Http, and view the Properties window (F4), you should see a Path property that will give you some insight into where it's coming from (e.g. D:\Projects\MyProject\packages\Microsoft.AspNet.WebApi.Core.5.1.0\lib\net45\System.Web.Http.dll). Does yours come from Microsoft.AspNet.WebApi.Core as well?Parahydrogen
W
14

This is what I did to solve an issue very similar to yours:

Error 2 Assembly 'Breeze.WebApi2, Version=1.4.0.0, Culture=neutral, PublicKeyToken=f6085f1a45e2ac59' uses 'System.Web.Http, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' c:\Repos\SPACodeCamper\packages\Breeze.Server.WebApi2.1.4.12\lib\Breeze.WebApi2.dll CC.Web

I got this error while doing the course Building Apps with Angular and Breeze - Part 1 by John Papa. It happened on step 3.15 after adding the Breeze Web API Controller to CC.Web.

To solve it we need to update the following NuGet Packages. I used NuGet Package Manager in Visual Studio 2013:

  1. Microsoft.AspNet.WebApi.Client from 5.0.0 to 5.1.2
  2. Microsoft.AspNet.WebApi.Core from 5.0.0 to 5.1.2
  3. Microsoft.AspNet.WebApi.WebHost from 5.0.0 to 5.1.2
  4. Microsoft.AspNet.WebApi.OData from 5.0.0 to 5.1.2 (this one I had to restart Visual Studio to complete the installation)

Updating the NuGet packages above will take care of bumping System.Web.Http's version to the correct one, in this case 5.1.0.0.

Wilek answered 13/5, 2014 at 19:26 Comment(1)
hehehe a comment from @John Papa! Isn't the internet so cool!? BTW, here's a readme with additional changes I had to do along the course: github.com/leniel/SPACodeCamper/blob/master/README.txt it's still work in Progress at the moment.Wilek
S
1

I think your answer is given here.

You have to update the NuGet packages. The easiest one is update-package in the NuGet packet manager console.

Be aware of other dependencies that might break.

Sectarian answered 12/5, 2014 at 17:16 Comment(0)
A
0

I solved this by updating all my packages from NuGet.

Armenia answered 15/10, 2015 at 18:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.