有天他登入後,查看Issue List, 點選了某一筆的IssueTitle, 接著畫面就呆住不動等啊等的,出現了了這個錯誤.
Object reference not set to an instance of an object.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]BugNET.Issues.IssueDetail.SetFieldSecurity() in C:\BugNet\WebSite\Issues\IssueDetail.aspx.cs:487
BugNET.Issues.IssueDetail.Page_PreRender(Object sender, EventArgs e) in C:\NET\BugNet\WebSite\Issues\IssueDetail.aspx.cs:139
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.PreRenderRecursiveInternal() +112
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4184
debug後在 IssueDetail.aspx.cs SetFieldSecurity 方法, 倒數幾行
if (!ITUser.HasPermission(ProjectId, Globals.Permission.CLOSE_ISSUE.ToString()))
{
Status s = Status.GetStatusByProjectId(ProjectId).Find(delegate(Status status){return status.IsClosedState == true;});
if (s !=null)
{
DropDownList stat = (DropDownList)DropStatus.FindControl("dropStatus");
stat.Items.Remove(stat.Items.FindByValue(s.Id.ToString()));
}
}
加入紅字判斷物件是否存在即可.
另外原先下載的sourcre中,少了一個 /jHtmlArea/scripts/jHtmlArea-0.7.0.js目錄及檔案,導致查看issue detail時,會有javascript 找不到屬性或方法的錯.
可以到此網站下載, 在專案中將目錄及檔案加入即可,不然開啟查看明細的page時,要等很久.