Windows runtime 温特。未处理的异常处理程序。StackTrace为空
我在WinForms上有一个项目,代码如下:Windows runtime 温特。未处理的异常处理程序。StackTrace为空,windows-runtime,windows-store-apps,windows-store,Windows Runtime,Windows Store Apps,Windows Store,我在WinForms上有一个项目,代码如下: AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; private void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) { } int a=0; .... try { int i = 1 / a;
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
private void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{ }
int a=0;
....
try
{
int i = 1 / a;
}
catch (Exception exp)
{
throw;
}
e.ExceptionObject
包含完整的堆栈跟踪
Win商店内项目:
this.UnhandledException += (s, e) =>{
{
MarkedUp.AnalyticClient.LogLastChanceException(e);
};
e、 Exception.StackTrace为空
这两个异常都是由以下代码生成的:
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
private void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{ }
int a=0;
....
try
{
int i = 1 / a;
}
catch (Exception exp)
{
throw;
}
有什么想法吗?您是否在调试模式下运行解决方案?在调试模式下运行解决方案时,App.g.i.cs文件中似乎发生了一些事情。当我在发布模式下运行示例时,stacktrace在UnhandledException事件中可用 在我的测试解决方案中,它首先在此处中断:
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
在这之后,它将转到我在app.xaml.cs文件中定义的未处理异常处理程序。在调试中,stacktrace消失,在发布模式中,stacktrace和异常详细信息存在。MSDN上的参考表明这是一个限制: 一个值得注意的限制是,UnhandledException事件参数包含的细节不如从应用程序代码传播的原始异常详细。只要有可能,如果应用程序需要对某个异常进行特定处理,那么最好在异常传播时捕获该异常,因为届时将提供更多详细信息。UnhandledException事件参数通过exception属性公开异常对象。但是,不能保证此异常对象的类型、消息和堆栈跟踪与引发的原始异常的类型、消息和堆栈跟踪匹配。事件参数确实公开了消息属性。在大多数情况下,这将包含最初引发的异常的消息