System.NullReferenceException: 未将对象引用设置到对象的实例。 at AspNetForums.Data.SqlDataProvider.GetForums(Int32 siteID, Int32 userID, Boolean ignorePermissions, Boolean mergePermissions) at AspNetForums.Data.SqlDataProvider.GetForums(Int32 siteID, Int32 userID, Boolean ignorePermissions) at AspNetForums.Forums.GetForums(ForumContext forumContext, Int32 userID, Boolean ignorePermissions, Boolean cacheable) at AspNetForums.Components.ForumContext.get_ForumLookupTable() at AspNetForums.Components.ForumContext.GetForumFromForumLookupTable(Int32 forumID) at AspNetForums.Controls.BreadCrumb.AddForum(Int32 forumID) at AspNetForums.Controls.BreadCrumb.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain()
产生这个异常的代码是: SqlDataProvider.cs 文件中 第3223行
((Forum) forums[f.ParentID]).Forums.Add(f);
当系统读取子版块信息时,会尝试从 forums 集合中取父版块的引用.此时,因为父版块已被禁用,并没有包含在 forums 中,从而就造成了异常的产生.
解决方案:
1.修改代码.
把SqlDataProvider.cs 文件中 第3222行
if (f.ParentID > 0)
((Forum) forums[f.ParentID]).Forums.Add(f);
}
修改为:
if (f.ParentID > 0 && forums[f.ParentID] != null)
((Forum) forums[f.ParentID]).Forums.Add(f);
}
2.修改存储过程
因为小第属SQL低手,在此只提供建议,不做实施.
可以通过修改存储过程 forums_Forums_Get 使其在取论坛信息的时候就不取禁用的版块的子版块.如果哪位大虾改好了希望可以告诉我一声.
本文地址:http://com.8s8s.com/it/it8551.htm