1
我保持在生產ASP.Net應用程序得到以下警告(未錯誤):收藏已修改;枚舉動作可以不執行
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Web.UI.ControlCollection.ControlCollectionEnumerator.MoveNext() at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at DMAC.UI.Master.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Page.Render(HtmlTextWriter writer) at Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Page.Render(HtmlTextWriter writer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.scan_history_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
下面是渲染方法,其中所述錯誤發生的代碼:
protected override void Render(HtmlTextWriter writer)
{
Header header = new Header();
List<Menu> menus = DMAC.Application.Current().Menus;
Menu menu = menus.Find(m => m.MenuId == MenuId);
SiteMapWindow siteWindow = new SiteMapWindow();
siteWindow.OpenerId = Menu.PATHID;
this.Page.Form.Controls.Add(siteWindow);
SupportWindow supportWindow = new SupportWindow();
supportWindow.OpenerId = Menu.SUPPORTID;
this.Page.Form.Controls.Add(supportWindow);
this.Page.Form.Controls.AddAt(0, menu);
this.Page.Form.Controls.AddAt(0, header);
Scripts.GoogleAnalytics.RegisterScript(this.Page);
base.Render(writer);
}
我不能自己重新創建錯誤。有任何想法嗎?
我並不總是測試我的代碼;但是當我這樣做時,我會在生產中做到這一點。 – 2011-06-02 01:27:56
這沒有任何警告。 --Obi-Wan – 2011-06-02 01:29:01
@Brandon,渴望我的朋友。 – Marlon 2011-06-02 01:29:19