只是试图将一些代码从一个工作项目拼接到另一个。 “from”项目使用“属性路由”,您可以在 Web API Controller 模块中嵌入 [Route(…)]
指令来指示应该将哪个 HTTP 消息路由到哪个服务例程。
在“from”项目中工作正常,但在“to”项目中我收到构建错误“找不到类型或 namespace 名称‘Route’(是否缺少 using 指令或程序集引用?) "
我已经尝试将“from”项目中的所有using
语句基本上复制到“to”项目中,但这没有明显效果。没有任何 MS 文档表明需要 NuGet 包(甚至是 using
语句)。这两个项目都应该是 ASP.NET MVC 4。
(是的,我用 config.MapHttpAttributeRoutes();
语句更新了 WebApiConfig.cs。)
有什么想法吗??
最佳答案
Vedran Mandić 的这条评论为我解决了这个问题。我在这里重新发布它,因为我认为它应该是答案(或至少是答案)。
I did an 'Update-Package Microsoft.AspNet.WebApi.WebHost -reinstall' and it worked. Funny this happens after getting the latest version on different PCs from TFS. I guess this happens because of nuget packages not working properly with the versioning system
关于c# - "The type or namespace name ' 使用 ' could not be found"路由 "attribute routing",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24419324/