巧合的是,我看了一下Visual Studio的调试输出.我可以看到数以百计的各种异常被抛出.我检查了另一个基于ASP.NET的解决方案,它显示相同的行为.为什么抛出所有这些例外?我不敢相信这对整体表现有好处,是吗?请看下面的摘录.它是appr的输出.30秒冲浪.大多数是HttpExceptions,但也有FormatExceptions和ArgumentOutOfRangeExceptions.这些都不会影响使用.什么都没有崩溃.有没有人有解释,因为它似乎是"正常的"?
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
'w3wp.exe' (Managed): Loaded 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a402e511\e6aaa0de\App_Web_vdj_eurz.dll', Symbols loaded.
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll
A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dll
A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
Run Code Online (Sandbox Code Playgroud)
Ted*_*sen 35
我不确定究竟是什么导致它,但我知道你怎么能找到(更好,对吧?:)).
在Visual Studio中:
这将使Visual Studio在任何异常上暂停调试器,以便您可以检查实际发生的情况.(不影响生产代码,只在VS中暂停)
作为旁注,您可能希望实现类似自动例外电子邮件或类似的功能,以从生产站点获取更多信息.
请注意,您可能无法捕获VS中的所有异常(第一次异常有时可能有点难以捉摸).如果你想要更加强硬,你可以让Visual Studio调试器调试.Net Framework.你的目标应该是看到完整的异常+堆栈跟踪,这在大多数情况下会告诉你所有的错误.
一个好的做法是摆脱异常(找到原因和修复),不要隐藏或忽略它们.
编辑
同样值得一提的是," 第一次机会异常 "是可能被try-catch捕获的异常..Net中的某些内部函数会在满足某个条件时抛出异常,这是Visual Studio /调试工作方式的一部分,并不意味着某些事情已经崩溃.Visual Studio将为您记录这些内容,以防您需要它们,但这并不意味着您必须对它们采取行动.
小智 23
谁知道???
但你可以找到.点击ctrl-alt-E,然后在Exceptions对话框中指示调试器在抛出异常时中断:

当它中断时,检查InnerException属性以查看导致HttpException的原因.
查看此 URL 以详细了解这些消息:http://blogs.msdn.com/b/davidklinems/archive/2005/07/12/438061.aspx。
如果您愿意,可以通过以下方式禁用此输出:
工具 --> 选项 --> 调试 --> 常规 --> 取消选中将所有输出窗口文本重定向到立即窗口
| 归档时间: |
|
| 查看次数: |
42375 次 |
| 最近记录: |