gpt4 book ai didi

asp.net - Application Insight 中的 MVC 异常隐藏堆栈跟踪

转载 作者:行者123 更新时间:2023-12-03 03:08:24 24 4
gpt4 key购买 nike

我正在玩Application Insights (AI)尝试看看我是否可以记录和查看应用程序抛出的异常。

我关注了this guide设置链接到 Azure 中新 AI 资源的新 MVC 项目以进行测试。一切都运转良好。

在我阅读完以下指南后 Diagnose failures & exceptions ,我创建了一个新的操作方法,在其中触发 NullReferenceException。我真的很喜欢将遥测数据发送给人工智能的方式。调试应用程序时,我可以在 Application Insights 搜索窗口内查看 Visual Studio 中引发的异常。它给了我以下堆栈跟踪:

System.NullReferenceException: Object reference not set to an instance of an object.  
at WebApplicationInsights.Controllers.HomeController.Error (HomeController.cs:33) (WebApplicationInsights, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
at lambda_method (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
.
.
at System.Web.HttpApplication.ExecuteStep (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)

如您所见,异常是从 HomeController 引发的。

现在,在发布到 Azure 后,我通过访问 live 网站再次引发了此异常。检查 Azure 门户中的异常,我得到以下堆栈跟踪:

System.NullReferenceException:  
at lambda_method (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
.
.
at System.Web.HttpApplication.ExecuteStep (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)

您可以观察到堆栈跟踪中的最后一个调用丢失了。为什么?
本地调试时引发的异常也出现在 Azure 门户中,但是这个没有缺少最后一次调用。请参阅此屏幕截图:

enter image description here

其他问题:匿名托管的 DynamicMethods Assembly 在堆栈跟踪中代表什么以及为什么它在那里?

最佳答案

当您发布时,您可能会发布发布配置(默认),以便启用代码优化。如果您愿意放弃,您可以切换到发布调试(这会对性能产生影响)或在 Release模式下禁用某些代码优化(更多 here )。

关于asp.net - Application Insight 中的 MVC 异常隐藏堆栈跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42165618/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com