[英]C# - Cannot call a HttpConfiguration Extension Methods
I cannot call an HttpConfiguration
extension method:我无法调用HttpConfiguration
扩展方法:
using System.Configuration;
using System.Web.Http;
...
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes(); // <-- error
Error: 'System.Web.Http.HttpConfiguration' does not contain a definition for 'MapHttpAttributeRoutes' and no extension method 'MapHttpAttributeRoutes' accepting a first argument of type 'System.Web.Http.HttpConfiguration' could be found (are you missing a using directive or an assembly reference?)错误:“System.Web.Http.HttpConfiguration”不包含“MapHttpAttributeRoutes”的定义,并且找不到接受“System.Web.Http.HttpConfiguration”类型的第一个参数的扩展方法“MapHttpAttributeRoutes”(您是否缺少使用指令或程序集引用?)
I tried both with System.Web.Http version 4 and 5, and with ".NET Framework 4.5.2" and ".NET Framework 4".我尝试了 System.Web.Http 版本 4 和 5,以及“.NET Framework 4.5.2”和“.NET Framework 4”。
What am I missing?我错过了什么?
Make sure you have a reference to Assembly System.Web.Http.dll, v5.2.3.0
in your project where that code is being executed.确保在执行该代码的项目中引用了Assembly System.Web.Http.dll, v5.2.3.0
。 HttpConfigurationExtensions.MapHttpAttributeRoutes
was added to ASP.NET Web API 2.2 which requires the above mentioned version of the assembly. HttpConfigurationExtensions.MapHttpAttributeRoutes
已添加到 ASP.NET Web API 2.2,它需要上述版本的程序集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.