Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net System.InvalidOperationException:堆栈为空_Asp.net_Asp.net 4.0_Visual Studio 2013 - Fatal编程技术网

Asp.net System.InvalidOperationException:堆栈为空

Asp.net System.InvalidOperationException:堆栈为空,asp.net,asp.net-4.0,visual-studio-2013,Asp.net,Asp.net 4.0,Visual Studio 2013,在运行Visual Studio 2013中内置的ASP.NET 4.x应用程序后,我遇到以下异常 我已尝试通过删除页面检查器程序集来禁用页面检查器 <assemblies> <remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </assem

在运行Visual Studio 2013中内置的ASP.NET 4.x应用程序后,我遇到以下异常

我已尝试通过删除页面检查器程序集来禁用页面检查器

<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)
[/Pages/TargetPage.aspx]System.Web.HttpException(0x80004005):引发了类型为“System.Web.HttpException”的异常。-->System.Web.HttpUnhandledException(0x80004005):引发了类型为“System.Web.HttpUnhandledException”的异常。-->System.InvalidOperationException:堆栈为空。
在System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource资源)处
位于System.Collections.Generic.Stack`1.Pop()
在Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.EndRendering(TextWriter编写器,对象RenderObject)
位于System.Web.UI.RenderTraceListener.RenderTraceListenerList.EndRendering(TextWriter编写器,对象RenderObject)
位于System.Web.UI.Control.RenderControlInternal(HtmlTextWriter编写器、ControlAdapter适配器)
位于System.Web.UI.Control.RenderControl(HtmlTextWriter编写器、控制适配器)
位于System.Web.UI.Control.RenderControl(HtmlTextWriter)
在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)
位于System.Web.UI.Page.HandleError(异常e)
在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)
在System.Web.UI.Page.ProcessRequest(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)
在System.Web.UI.Page.LegacyPageAsyncInfo.b\uuu32(对象o)
位于System.Web.HttpContext.InvokeCancellableCallback(WaitCallback回调,对象状态)
位于System.Web.UI.Page.LegacyPageAsyncInfo.CallHandlersPossiblyUnderLock(布尔onPageThread)
位于System.Web.UI.Page.LegacyPageAsyncInfo.CallHandlers(布尔onPageThread)
在System.Web.HttpAsyncResult.End()处
位于System.Web.UI.Page.LegacyAsyncPageEndProcessRequest(IAsyncResult结果)
位于System.Web.UI.Page.AsyncPageEndProcessRequest(IAsyncResult结果)
有没有办法避免这种异常?
非常感谢您的建议

我发现了问题所在。GridView中控件ID的生成方式从默认更改为

ClientIDMode="Predictable" ClientIDRowSuffix="ID"
这导致了例外。不确定PageInspector堆栈empty隐藏真正异常的原因。只需将更改恢复为原始即可解决问题

现在例外情况有所不同(但一旦GridView设置恢复到原始设置,这也会消失)


我也有同样的例外,但就我而言,问题在于缺少以下内容:

<form runat="server">
</form>

我在使用Visual Studio 2013并启用“浏览器链接”的开发人员机器上运行的一些web应用程序中也发现了这个问题


在我见过的多种情况下,启用浏览器链接会导致各种问题,包括客户端脚本和安全警告,以及类似这样的服务器异常(恼人的是,它似乎是默认启用的,感谢Msft!)

我在VS 2013中禁用了浏览器链接,并且能够看到错误的实际原因。它通常是设置浏览器链接时的基础内容。您可以在此处看到如何禁用它:

有多种原因导致

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>

...

我注意到我在一个下拉列表中复制了所选的项目,从而产生了这个问题。

希望这对其他人有所帮助


当我的
asp:panel
有一个默认按钮,说XYZ时,我遇到了这个错误,我修改了名称XYZ,忘了更改panel中的默认按钮名称。

如果标签上的
关联控件ID
与找不到的控件关联,就会发生这种情况。

(ASP.NET 4.6,Visual Studio 2015) 我注释了一个asp文本控件并添加了一个新的asp下拉列表,但没有更新关联标签的AssociatedControlID


在将关联的ControlID更改为新添加的asp下拉列表ID时,我的问题已得到解决。

我们启动了VisualStudio 2015(vs2015)从VisualStudio 2012解决方案文件,在生成所有项目时未生成。这是由于默认情况下启用了“启用浏览器链接”选项。我禁用了“启用浏览器链接”选项,并重新生成了成功生成所有项目的解决方案。在此之后,我在浏览器中启动了url并启动它!对于那些具有类似于我的场景。试一试!

当我在页面中添加新的
并将
DefaultButton
设置为面板外的按钮时(错误地),我遇到了这种情况。
当我将
DefaultButton
更改为面板内的另一个按钮时,已修复错误。

在我的情况下,由于将网站从VS2002迁移到VS2015时遇到了很多问题,我决定在VS2015上创建一个新项目,并将所有webforms从旧项目(VS2002)转移到新项目(VS2015)

新项目有一个Site.Master页面,它已经有了一个标记。因为我在未经修改的情况下传输旧的webforms,它们也已经有了一个标记,所以每个试图加载的页面都有两个标记

当我删除每个页面上的标签,只在Site.Master页面上留下一个标签时,问题就解决了。


我希望这会有所帮助。

我在选择不同的下拉值时会遇到这个问题,下面是问题的解决方案

首先清除下拉列表的选定值,然后启用其他下拉列表值选择

dropdown.ClearSelection();
dropdown.Items.FindByValue(result.Birthday.Value.Year.ToString()).).Selected = true;

谢谢,添加解决了我的问题!@mybrave:你能为“PageInspector:ServerCodeMappingSupport”键写一个答案吗,因为这似乎是很多人(对我也是)的解决方案。在VS 2017中也很有帮助这是一个死链接。下面是一个有效的链接:
dropdown.ClearSelection();
dropdown.Items.FindByValue(result.Birthday.Value.Year.ToString()).).Selected = true;