Visual Studio 在 StackOverflowException 上丢失第一个堆栈帧

Visual Studio loses first stack frames on StackOverflowException

我是 运行 网络爬虫并使用 HtmlAgilityPack 解析页面内容并在该 C# 库中随机获取 WhosebugException,但是当我尝试查看调用堆栈列表直至我的代码时,我得到:

"The maximum number of stack frames supported by Visual Studio has been exceeded."

旁注:我已经在使用 sjdirect's HAP 修复。

这是一张快照(一路这样重复)。

有没有办法增加 Visual Studio 可以跟踪的堆栈帧的数量,至少增加到应用程序在填充其堆栈之前可以分配的数量?还是可以反过来,即减少被调试应用程序的堆栈大小?

WhosebugExceptions 的问题在于它们太深了,以至于堆栈实际上变成了垃圾。 This page 有一个导致这种情况的递归示例,最终堆栈上有 80,000 个级别。

考虑到我上次阅读的 VS 仍然是模拟 64 位调试的 32 位应用程序,您可能远远超过了 VS 的可用内存来为您管理堆栈级别的数量。

没有明显的功能来限制 CLR 应用程序的堆栈大小或增加 Visual Studio 的跟踪堆栈帧计数。

作为解决方案,我将放弃使用 HtmlAgilityPack 来提取文本(例如 this aren't really solutions) and write myself an old fashioned HTML to text parser or try one of the answers other similar questions posted on Whosebug (very similar to Matt Crouch's question,尽管 none 的答案适合从数千页中提取可呈现的文本)

编辑: 虽然通常不推荐使用正则表达式,但这实际上解决了我的问题(无需处理 WhosebugException):Convert HTML to Plain Text

感谢您的努力,希望这对其他人有所帮助。