【问题标题】:the namespace RoleExists does not exist in the namespace error命名空间 RoleExists 不存在于命名空间错误
【发布时间】:2014-05-09 03:33:41
【问题描述】:

基于this link我创建了一个Role,但出现如下错误:

命名空间RoleExists在命名空间testproject中不存在。

角色和我的代码如下所示:

namespace testproject.Roles
{
    public partial class ManageRoles : System.Web.UI.Page
    {
        protected void CreateRoleButton_Click(object sender, EventArgs e)
        {
            string newRoleName = RoleName.Text.Trim();

            if (!Roles.RoleExists(newRoleName)) // Create the role 
                Roles.CreateRole(newRoleName); 

            RoleName.Text = string.Empty;
        }
    }
}

【问题讨论】:

    标签: c# asp.net namespaces


    【解决方案1】:

    角色有歧义:替换

    if (!Roles.RoleExists(newRoleName)) // Create the role 
    

    与

    System.Web.Security.Roles.RoleExists(newRoleName)) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-23
      • 2014-10-02
      • 2013-05-24
      • 1970-01-01
      • 2011-10-19
      • 2019-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多