uwp app(.net native)和未处理的异常

时间:2017-12-28 06:46:12

标签: c# uwp unhandled-exception hockeyapp .net-native

我为Windows 10桌面创建了uwp app(.Net native)。我使用HockeyApp收集实时崩溃报告。堆栈跟踪不提供信息。这是一个长期存在的问题,并没有解决方案。我试过了this但是没有用。 我得到以下例外:

csrfmiddlewaretoken

在我的计算机上,应用程序运行稳定。也许这是由于Windows的版本。我认为这是由于我的xaml。对我来说纠正这些错误非常重要。但我不能拒绝这张桌子。 任何想法如何找到这些错误的来源?

1 个答案:

答案 0 :(得分:5)

很抱歉,这可能不是答案,但我在评论栏中没有足够的空间。

App.xaml.cs中尝试以下操作。为这些事件添加处理程序,看看他们是否向您报告崩溃事件。

public App()
{
    UnhandledException += OnUnhandledException;
    TaskScheduler.UnobservedTaskException += OnUnobservedException;

    InitializeComponent();
}

private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
    // Occurs when an exception is not handled on the UI thread.


    // if you want to suppress and handle it manually, 
    // otherwise app shuts down.
    e.Handled = true; 
}

private static void OnUnobservedException(object sender, UnobservedTaskExceptionEventArgs e)
{
    // Occurs when an exception is not handled on a background thread.
    // ie. A task is fired and forgotten Task.Run(() => {...})


    // suppress and handle it manually.
    e.SetObserved();
}