【发布时间】:2019-09-14 10:02:08
【问题描述】:
更新:经过多次尝试,发现连String都不能识别,只能识别字符串。
如果我从 MVC 模板创建新项目,同时在 立即窗口 中进行调试 我能做到:
var a = new List<int>{1,2,3};
a.First()
但是在我现有的项目中,如果我尝试这样做:
var a= new List{1,2,3};
它给了我
error CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)
另一方面,我可以做到这一点。
var a = new System.Collections.Generic.List<int>{1,2,3};
但这次
a.First() 给我
error CS1061: 'List<int>' does not contain a definition for 'First' and no accessible extension
我也有顶级剃须刀视图页面
@using System;
@using System.Linq;
@using System.Collections.Generic
事实上,过去一切都习惯于在没有对网络配置进行任何更改的情况下工作。
我的现有项目可能有什么问题,我既不能使用也不能列出 Linq 表达式?
我的真实情况是,我想在调试时在剃刀视图中使用 linq lambda 表达式。
谜团解开,在我看来我有 Kendo ui mvc 流利的表达方式:
@(Html.Kendo().Window()
.Modal(true)
.Width(350)
.Height(280)
.Actions(a => a.Custom("ActivateRole"))
.Animation(true)
.Content(FormContent().ToHtmlString())
.Name("RoleSelector")
.Events(eve => eve.Activate("centerKendoWindow"))
.Title("Role selection")
)
form表单内容,我有
@helper FormContent()
{
}
因此,我“失去上下文”然后忽略所有命名空间。
【问题讨论】:
-
您在运行时遇到这些错误?还是在编译时?
-
在断点暂停应用程序时调试运行时
-
您使用的是哪个版本的 MVC?这在 MVC 5 中运行良好。
-
感谢您的检查,MVC 5.2.3.0 也是如此。我注意到它曾经可以工作,但后来在相同的库中可以工作。
标签: c# asp.net-mvc debugging razor