C#-无法调用HttpConfiguration扩展方法

C#-无法调用HttpConfiguration扩展方法,c#,.net,asp.net-web-api2,extension-methods,asp.net-web-api-routing,C#,.net,Asp.net Web Api2,Extension Methods,Asp.net Web Api Routing,我无法调用HttpConfiguration扩展方法: using System.Configuration; using System.Web.Http; ... var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); // <-- error 使用系统配置; 使用System.Web.Http; ... var config=新的HttpConfiguration(); c

我无法调用
HttpConfiguration
扩展方法:

using System.Configuration;
using System.Web.Http;
...
      var config = new HttpConfiguration();
      config.MapHttpAttributeRoutes();  // <-- error
使用系统配置;
使用System.Web.Http;
...
var config=新的HttpConfiguration();

config.maphttpAttribute路由();// 确保在执行代码的项目中有对
Assembly System.Web.Http.dll,v5.2.3.0
的引用
HttpConfigurationExtensions.MapHttpAttribute路由已添加到ASP.NET Web API 2.2中,该程序集需要上述版本的程序集。

修复了此问题(严格与在Project>Reference Manager中指定:

Microsoft.Owin  2.0.2.0
Owin  1.0.0.0
System.Net.Http.Formatting  5.2.3.0
System.Web  4.0.0.0
System.Web.Http  5.2.3.0
System.Web.Http.Owin  5.2.3.0

这对我来说很好。var config=new System.Web.Http.HttpConfiguration();config.maphttpAttribute路由()@Pietro,确保在执行代码的项目中有对Assembly System.Web.Http.dll的引用。还可以尝试清除bin文件夹,然后重建project@Nkosi,我选择了它。只是对它的版本有点怀疑。我有:System.webv。4.0,System.Web.httpv。4.0和System.Web.Http.Owin v。5.2.3. 我可以访问System.Web.httpv。5.2.3(匹配Owin),但没有System.Web>4.0。这可能是个问题吗?@Pietro,是的。使用System.Web的v5.2.3.0。Http@Nkosi,我做到了,我还升级了System.Web.Http.Formatting。它现在起作用了。谢谢。是的,但我还需要将
System.Net.Http.Formatting
升级到5.2.3.0。