Search code examples
windows-runtimewindows-store-appswindows-store

WinRt. UnhandledException handler. StackTrace is null


I have a project on WinForms with this code:

AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

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

The e.ExceptionObject contains full StackTrace.

In Win Store project:

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

e.Exception.StackTrace is null.

Both exceptions were generated by this code:

int a=0;
....

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

Any Ideas?


Solution

  • The reference on MSDN suggests that this is a limitation: 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.