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

EmbeddedResourceVirtualPathProvider和@Html.TextBoxFor(Linq表达式),linq,razor,virtualpathprovider,Linq,Razor,Virtualpathprovider,在我的.cshtml文件中,无论在哪里使用@Html.TextBoxFor,我都会遇到一个错误 下面是一个示例代码: @model WebComposite.Models.CompositeModel <label for="name">Name</label> @Html.TextBoxFor(m => m.name) @model WebComposite.Models.CompositeModel 名称 @Html.TextBoxFor(m=>m.name

在我的.cshtml文件中,无论在哪里使用@Html.TextBoxFor,我都会遇到一个错误

下面是一个示例代码:

@model WebComposite.Models.CompositeModel

<label for="name">Name</label>
@Html.TextBoxFor(m => m.name)
@model WebComposite.Models.CompositeModel
名称
@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:
无法从用法推断“System.Web.Mvc.Html.InputExtensions.TextBoxFor(System.Web.Mvc.HtmlHelper,System.Linq.Expressions.Expression)”。尝试显式指定类型参数。
错误#2:
找不到编译动态表达式所需的一个或多个类型。你错过了推荐人吗?

有什么想法吗?

如果有人想知道,我是如何解决的:

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,添加适当的引用,进行构建,一切都应该恢复正常