EmbeddedResourceVirtualPathProvider和@ Html.TextBoxFor(Linq表达式)

时间:2014-01-17 21:27:55

标签: linq razor virtualpathprovider

在我的.cshtml文件中,无论我在哪里使用@ Html.TextBoxFor

我都会收到错误

这是一个示例代码:

@model WebComposite.Models.CompositeModel

<label for="name">Name</label>
@Html.TextBoxFor(m => m.name)

错误:

Error #1:
'System.Web.Mvc.Html.InputExtensions.TextBoxFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Error #2: 
One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?

任何想法?

1 个答案:

答案 0 :(得分:0)

万一其他人想知道,这是我如何解决它:

1. right click on the project -> select properties
2. select Application
3. change "target framework" (I was at 4.5, so I changed it to 4)
4. change "target framework" to whatever it was before step 3

清理web.config,添加适当的引用,进行构建,一切都应该恢复正常