首页 > 解决方案 > Xbox UWP 不会崩溃

问题描述

我在为 Xbox 构建的 UWP 应用程序上工作。我想让它崩溃,以便我确认崩溃报告工作正常。我已经设置了调用此代码的按钮:

Object obj = null;
obj.ToString();

如果我将应用程序部署到我的 Windows 10 笔记本电脑并单击“崩溃”按钮,应用程序会崩溃(消失),正如我所料。但是,在单击该按钮后部署到 Xbox(在开发模式下)时,应用程序会挂起几秒钟,然后再次响应并且不会崩溃。

任何想法为什么这会发生在 Xbox 上?

标签: uwpxbox

解决方案


Not sure why, but on Xbox if that crash code is on the UI thread, it won't kill the app.

I solved this by creating a new thread and bow the app crashes as I need it to.

public static void CrashTheApp()
{
    Object obj = null;
    obj.ToString();
}

private void CrashTheApp_Click(object sender, RoutedEventArgs e)
{ 
    Thread thread = new Thread(App.CrashTheApp);
    thread.Start();
}

推荐阅读