加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows-runtime – WinRt. UnhandledException处理程序. StackT

发布时间:2020-12-14 02:50:21 所属栏目:Windows 来源:网络整理
导读:我在WinForms上有一个带有以下代码的项目: AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;private void CurrentDomainUnhandledException(object sender,UnhandledExceptionEventArgs e){ } e.ExceptionObject包含完整的
我在WinForms上有一个带有以下代码的项目:

AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

private void CurrentDomainUnhandledException(object sender,UnhandledExceptionEventArgs e)
{            }

e.ExceptionObject包含完整的StackTrace.

在Win Store项目中:

this.UnhandledException += (s,e) =>{                                               
{                                              
    MarkedUp.AnalyticClient.LogLastChanceException(e);
};

e.Exception.StackTrace为null.

这两个例外都是由这段代码生成的:

int a=0;
....

try
{
    int i = 1 / a;
}
catch (Exception exp)
{
    throw;
}

有任何想法吗?

解决方法

MSDN上的参考表明这是一个限制: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.application.unhandledexception

A notable limitation is that the UnhandledException event arguments don’t contain as much detail as the original exception as propagated from app code. Whenever possible,if the app requires specific processing of a certain exception,it’s always better to catch the exception as it propagates,because more detail will be available then. The UnhandledException event arguments expose an exception object through the Exception property. However,the type,message,and stack trace of this exception object are not guaranteed to match those of the original exception that was raised. The event arguments do expose a Message property. In most cases,this will contain the message of the originally raised exception.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读