使用MvcBuildViews构建Razor = true失败

时间:2012-04-11 17:44:09

标签: asp.net asp.net-mvc-3 razor msbuild

我使用MvcContrib和MvcScaffold构建了一个新项目。动态编译一切正常。但是,当我打开项目文件中的视图编译时,编译会中断。

The name 'model' does not exist in the current context
'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'LabelFor' and no extension method 'LabelFor' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'EditorFor' and no extension method 'EditorFor' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'ValidationMessageFor' and no extension method 'ValidationMessageFor' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)

如果你是left out the web.config file from the Views folder,那就是你会收到的同样的错误,但那是错误的。我也已经Phil Haack's fix,但无济于事。为什么MSBuild没有找到MVC3好东西?

1 个答案:

答案 0 :(得分:1)

我发现我在配置文件中意外复制了system.web部分,导致了同样的错误。