asp.net-4.0 - ASP.NET System.InvalidOperationException: 堆栈为空

在Visual Studio 2013中构建之后,运行ASP.NET 4.x应用程序,得到以下异常。

我试图通过删除page检查器程序集来禁用PageInspector


<assemblies>


 <remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>


</assemblies>



并将此配置添加到应用程序设置


<appSettings>


 <add key="PageInspector:ServerCodeMappingSupport" value="Disabled"/>


</appSettings>



没有帮助。


[/Pages/TargetPage.aspx] System.Web.HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown. ---> System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: Stack empty.


 at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)


 at System.Collections.Generic.Stack`1.Pop()


 at Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.EndRendering(TextWriter writer, Object renderedObject)


 at System.Web.UI.RenderTraceListener.RenderTraceListenerList.EndRendering(TextWriter writer, Object renderedObject)


 at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)


 at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)


 at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)


 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


 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.LegacyPageAsyncInfo.<CallHandlersPossiblyUnderLock>b__32(Object o)


 at System.Web.HttpContext.InvokeCancellableCallback(WaitCallback callback, Object state)


 at System.Web.UI.Page.LegacyPageAsyncInfo.CallHandlersPossiblyUnderLock(Boolean onPageThread)


 at System.Web.UI.Page.LegacyPageAsyncInfo.CallHandlers(Boolean onPageThread)


 at System.Web.HttpAsyncResult.End()


 at System.Web.UI.Page.LegacyAsyncPageEndProcessRequest(IAsyncResult result)


 at System.Web.UI.Page.AsyncPageEndProcessRequest(IAsyncResult result)



有没有办法避免异常?

时间:

有很多原因,


System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. -


System.InvalidOperationException: Stack empty.


Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.EndRendering(TextWriter writer, Object renderedObject)


...



添加后建议:


 <appSettings>


 <add key="PageInspector:ServerCodeMappingSupport" value="Disabled"/>


 ...


 </appSettings>



我禁用了VS 2013中的浏览器链接,可以看到错误的实际原因,你可以在这里看到如何禁用它:http://www.poconosystems.com/software-development/how-to-disable-browser-link-in-visual-studio-2013/

如果标签上的AssociatedControlID无法与控件相关联,就可能发生这种情况。

asp:panel有一个默认的按钮,比如说XYZ,我修改了名称XYZ,忘记更改面板的默认按钮名时,我得到这个错误。


<form runat="server">


</form>



当我向页面添加新的将DefaultButton更改为面板内部的另一个时出现错误。

...