Mar*_*inM 5 c# razor visual-studio-2013 asp.net-mvc-5
我在Visual Studio中遇到问题,我在MVC5剃刀视图中遇到一行调用ViewBag的错误.
@{
ViewBag.Title = "Home Page";
}
Run Code Online (Sandbox Code Playgroud)
错误是one or more types required to compile a dynamic expression, are you missing a reference.
我一直在寻找解决方案.一些帖子要求我添加对Microsoft.Csharp v.4.0.30319的引用.这已经完成但仍然是问题.另一种解决方案是添加该行
<compilation debug="true" targetFramework="4.0" />
Run Code Online (Sandbox Code Playgroud)
到配置文件.这不能完成,因为我的目标是4.5,所以我把它改为4.5.仍然是同样的问题.
在视图中添加任何lambda也存在问题,例如
@Html.LabelFor(a=>a.Property);
Run Code Online (Sandbox Code Playgroud)
这也会导致错误:
'System.Web.Mvc.Html.LabelExtensions.LabelFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>, System.Collections.Generic.IDictionary<string,object>)' cannot be inferred from the usage. Try specifying the type arguments explicitly
奇怪的是,应用程序确实按预期运行,所以我认为这是某种Visual Studio问题.
欢迎任何帮助!
| 归档时间: |
|
| 查看次数: |
2599 次 |
| 最近记录: |