代码之家  ›  专栏  ›  技术社区  ›  Skillzore

删除的代码行出错,这是怎么回事?

  •  2
  • Skillzore  · 技术社区  · 8 年前

    Line 32:            ////authorization.Rules.Set(0, accessRule);
    Line 33:            ////configuration.Save(ConfigurationSaveMode.Minimal); 
    Line 34:            "**This is the red marked erroneous line**"
    Line 35:  
    Line 36:            //StackTrace stackTrace = new StackTrace();
    

    这是什么黑魔法?行中没有代码,甚至没有调用该行,但我得到的错误报告为:

    当前web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源。

    授权规则必须指定用户和/或角色的列表。

    源文件:C:\MyProject\Accounts。aspx。cs线:34

    然而,所有涉及授权的代码都被注释掉了,甚至没有调用该方法。方法:

    public static void WriteAccsToAuth(List<User> allAllowedUsers)
    {
        //Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
        //AuthorizationSection authorization = (AuthorizationSection)configuration.GetSection("system.web/authorization");
        //AuthorizationRule accessRule = new AuthorizationRule(AuthorizationRuleAction.Allow);
        ////foreach (User usr in allAllowedUsers)
        ////{
        ////    accessRule.Users.Add(usr.Domain + "\\" + usr.UserName);
        ////}
        ////Debug.WriteLine("Users count: " + accessRule.Users.Count);
        ////Debug.WriteLine("Rules count: " + authorization.Rules.Count);
        ////authorization.Rules.Set(0, accessRule);
        ////configuration.Save(ConfigurationSaveMode.Minimal);
        "**This is the red marked erroneous line**"
    
        //StackTrace stackTrace = new StackTrace();
        //Debug.WriteLine("Users written to config file. Called by method " + stackTrace.GetFrame(1).GetMethod().Name + ".");
    }
    

    public static void LoadUsers()
    {
        ...
        //Accounts.WriteAccsToAuth(dbUsers.ToList());
        ...
    }
    

    我尝试过重建、重新启动Visual Studio和重新启动IIS。我的IIS是如何缓存错误的?我的意思是评论的行在错误消息中可见。。。我不知道这里发生了什么。

    2 回复  |  直到 8 年前
        1
  •  0
  •   Skillzore    8 年前

    我仍然对为什么会发生这种情况以及如何发生感到困惑,但清理解决方案并构建解决方案解决了这个问题。

        2
  •  0
  •   Chikwado    3 年前

    npm cache clean --force