出现错误 "The type or namespace name 'SelectList' could not be found" 即使我安装了 MVC,并且有 using 语句
Getting error "The type or namespace name 'SelectList' could not be found" even though I have MVC installed, and have the using statement
Git 将一个旧项目从工作中克隆到 VS 2015 中。构建项目时,出现错误
"The type or namespace name 'SelectList' could not be found"
我已经打开了 nuget 包管理器并确保 asp.net mvc 已经安装并且可以使用了。我还在 using 语句的顶部有语句 using System.Web.Mvc;
。
我通过包管理器更新了 mvc 以查看是否有帮助,但我仍然遇到错误。
using System.Web.Mvc;
using .....;
using .....;
namespace WorkPermit.Logic
{
public class RoleService : IDisposable
{
public SelectList GetRolesList()
{
var roles = _roleManager.Roles.Select(m => new SelectListItem()
{
Text = m.Name,
Value = m.Name,
}).ToList();
return new SelectList(roles, "Value", "Text");
}
}
}
因为我安装了 mvc 和 using 语句,我很好奇为什么会出现这个错误。
我找到了解决方案。导航到项目的 References 目录,删除并重新添加 System.Web.Mvc
引用。
Git 将一个旧项目从工作中克隆到 VS 2015 中。构建项目时,出现错误
"The type or namespace name 'SelectList' could not be found"
我已经打开了 nuget 包管理器并确保 asp.net mvc 已经安装并且可以使用了。我还在 using 语句的顶部有语句 using System.Web.Mvc;
。
我通过包管理器更新了 mvc 以查看是否有帮助,但我仍然遇到错误。
using System.Web.Mvc;
using .....;
using .....;
namespace WorkPermit.Logic
{
public class RoleService : IDisposable
{
public SelectList GetRolesList()
{
var roles = _roleManager.Roles.Select(m => new SelectListItem()
{
Text = m.Name,
Value = m.Name,
}).ToList();
return new SelectList(roles, "Value", "Text");
}
}
}
因为我安装了 mvc 和 using 语句,我很好奇为什么会出现这个错误。
我找到了解决方案。导航到项目的 References 目录,删除并重新添加 System.Web.Mvc
引用。