ASP.NET Web API error after upgrading to Visual Studio 2012 RC: Method not found: 'Void System.Net.Http.Headers.HttpHeaders.AddWithoutValidation

前端 未结 4 1859
终归单人心
终归单人心 2020-12-18 23:28

After upgrading to Visual Studio 2012 I can no longer access any of my ApiControllers, the following error is thrown:

Server Error in \'/\' Application.

Met         


        
相关标签:
4条回答
  • 2020-12-19 00:05

    This fixed it for me.

    http://forums.asp.net/t/1809919.aspx/1
    

    Method not found: 'Void System.Net.Http.Headers.HttpHeaders.AddWithoutValidation(System.String, System.Collections.Generic.IEnumerable`1)'.

    I resolved it with the following steps. Not sure if all of them are required, but it worked.

    In NuGet Package Manager, uninstalled the Web.API Beta package. Added references to System.Net.Http, System.Web.Http, & System.Web.Http.WebHost (these were removed by the previous step). Installed Json.Net via NuGet.

    As an addition, if your project is targeting the 4.0 version of the framework, you must include the new Microsoft ASP.Net Web API set of packages from NUGET, to get a green light for your build. Json.Net is a dependency for these new packages, so you need not install it separate.

    0 讨论(0)
  • 2020-12-19 00:17

    step 1 Remove the below references from your project:

    System.Net.Http, System.Web.Http, System.Web.Http.WebHost , System.Web.Http.Common & System.Net.Http.Formatting

    step 2 Add the above refefrences (except the System.Web.Http.Common & System.Net.Http.Formatting) from Below location

    1. C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.AspNet.WebApi.Core.4.0.20505.0\lib\net40

    2. C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.AspNet.WebApi.WebHost.4.0.20505.0\lib\net40

    3. C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.Net.Http.2.0.20505.0\lib\net40

    and add one more new dll Newtonsoft.Json.dll from

    1. C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Newtonsoft.Json.4.5.1\lib\net40
    0 讨论(0)
  • 2020-12-19 00:20

    Solution to this and other RC-related issues right here.

    0 讨论(0)
  • 2020-12-19 00:26

    You have a reference to an old version of System.Net.Http in your project. To fix this, go under "References" in your project, delete System.Net.Http, and add the version that comes with .NET 4.5 instead. That should do it.

    Henrik

    0 讨论(0)
提交回复
热议问题