[英]Visual Studio 2012 Can't compile Dynamic Expressions and Model types
我在Visual Studio 2012中遇到了一个大问题。每当我启动ASP.Net MVC4项目时,我都会遇到以下错误:
Cannot convert lambda expression to type 'System.Linq.Expressions.Expression<System.Func<Carrousel.Web.ViewModels.LoginViewModel,bool>>' because it is not a delegate type
One or more types required to compile a dynamic expression cannot be found. Are you missing a reference? d:\Visual Studio\Projects\School\Carrousel v2\Carrousel.Presentation\Views\Account\Login.cshtml
The type arguments for method '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.
当在cshtml文件中存在ViewBag和Html Form Helpers等动态表达式时会发生这种情况。
我一直在寻找,我找到的唯一原因是没有引用Microsoft.CSharp和/或System.Core。 但是我在项目中都引用了它们。
只有在使用Asp.Net Mvc 4时才会出现此问题,使用Mvc 3时一切正常。 我的Windows 7和Windows 8企业版都出现此错误。 我还尝试通过包管理器卸载并重新安装mvc4。
尝试删除并添加对以下程序集的引用:
Microsoft.Scripting.Core.dll
Microsoft.CSharp
同
CopyToLocal = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.