已添加项。提示

Oct 13, 2010 at 1:01 PM
Edited Oct 13, 2010 at 1:18 PM

已添加项。字典中的关键字:“TeacherManager.BLL.Teacher”所添加的关键字:“TeacherManager.BLL.Teacher”

 

这个  “已添加项。”错误提示经常出现,,特别是调试或使用Frame时,,

最好 使用某个设计模式防止下这个

 

奇怪的是源代码中已经加了lock,还会出现这种情况?????

 

        public virtual Type GetImplType(Type sourceType)
        {
            if (_dic.ContainsKey(sourceType))
            {
                return _dic[sourceType];
            }
            lock (_dic)
            {
                if (_dic.ContainsKey(sourceType))
                {
                    return _dic[sourceType];
                }
                Type t = GetImplementedType(sourceType);
                _dic[sourceType] = t;
                return t;
            }
        }

 

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentException: 已添加项。字典中的关键字:“TeacherManager.BLL.Teacher”所添加的关键字:“TeacherManager.BLL.Teacher”

源错误:

行 354:        public static Teacher GetByUserName(string username)
行 355:        {
行 356:            return FindOne( CK.K["UserName"] == username );
行 357:        }
行 358:


源文件: D:\SchoolWeb\TeacherManager\BLL\Teacher.cs    行: 356

堆栈跟踪:

[ArgumentException: 已添加项。字典中的关键字:“TeacherManager.BLL.Teacher”所添加的关键字:“TeacherManager.BLL.Teacher”]
   System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) +7485048
   System.Collections.Hashtable.Add(Object key, Object value) +11
   System.Collections.SyncHashtable.Add(Object key, Object value) +68
   Lephone.Data.DynamicObject.GetImplType(Type sourceType) +1199
   Lephone.Data.Common.ObjectInfo.GetInstance(Type dbObjectType) +46
   Lephone.Data.DbContext.DataLoad(IProcessor ip, Type dbObjectType, FromClause from, WhereCondition iwc, OrderBy oc, Range lc, Boolean isDistinct) +23
   Lephone.Data.DbContext.FillCollection(IList list, Type dbObjectType, WhereCondition iwc, OrderBy oc, Range lc, Boolean isDistinct) +46
   Lephone.Data.DbContext.GetObject(Type t, WhereCondition c, OrderBy ob, Range r) +50
   Lephone.Data.DbContext.GetObject(WhereCondition c) +70
   Lephone.Data.DbEntry.GetObject(WhereCondition c) +56
   Lephone.Data.Definition.DbObjectModelBase`2.FindOne(WhereCondition con) +45
   TeacherManager.BLL.Teacher.GetByUserName(String username) in D:\SchoolWeb\TeacherManager\BLL\Teacher.cs:356
   PageBase.GetCurTeacher() in d:\SchoolWeb\TeacherManager\WebSite\App_Code\PageBase.cs:54
   PageBase.get_CurTeacher() in d:\SchoolWeb\TeacherManager\WebSite\App_Code\PageBase.cs:46
   ChangePassword.Page_Load(Object sender, EventArgs e) in d:\SchoolWeb\TeacherManager\WebSite\ChangePassword.aspx.cs:21
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627



Coordinator
Oct 14, 2010 at 1:44 AM

尽量使用新版本。