1

I've been developing an app for Windows 8 and can test Suspend, Resume, Shutdown, etc. from Visual Studio 2012. However, when I test the app on a Microsoft Surface, there is one other state I can't seem to simulate.

When an app is open and you leave the Surface untouched for a bit, the screen will dim and then eventually shut-off. If I wait long enough, maybe 1 or 2 minutes, and hit the start button, it will take me to the Lock Screen, where I can sign in. Once I sign in, it will show my app where I left it. However, after 1 second, it crashes immediately, and the Surface takes me back to the Start Screen.

I cannot simulate this using Visual Studio and the Simulator. Suspending/Resuming using Debug Location does not recreate this.

I looked at the event log on the Surface and found that my app was crashing with the following:

The process was terminated due to an unhandled exception. 

Exception Info: System.Exception Stack: at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Threading.WinRTSynchronizationContext+Invoker.<InvokeCore>b__0(System.Object) at
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object) at
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

I have no clue how to find this. I am handling all unhandled exceptions with a standard message box, but it's not showing up. We've been very good at avoiding "async void" and making sure everything has "async Task" and awaited properly. So, I'm a bit stuck. I can't find where this is happening.

Anyone know how I can simulate this, or at least make the Event Log more verbose?

4

2 回答 2

2

在我看来,您拥有测试场景所需的一切。但是您可能不知道您可以在 Surface 上远程调试您的应用程序,就像它在本地运行一样。因此,您可以继续执行您的用例并让 Visual Studio 捕获异常:

这很简单。这是一个演练:http ://timheuer.com/blog/archive/2012/10/26/remote-debugging-windows-store-apps-on-surface-arm-devices.aspx

于 2013-01-23T19:53:30.177 回答
1

好的,我想通了。

MediaElement控制和音量有问题。当应用程序按照我上面的解释重新激活时,我们会收到音量已更改的通知。但是由于某种原因,如果我们尝试MediaElement.Volume在应用重新激活时进行操作,它会引发异常。这个异常没有消息,只是一些奇怪的十六进制数字。

这只发生在平板电脑上,而且很难检测到。本质上,对于所有播放媒体文件的人,您应该像这样尝试/捕捉它:

try
{
   myMediaElement.Volume = .3;
}
catch (Exception ex)
{
   // I don't really know what to do here.
   // but at least my app doesn't crash anymore :)
}

无论如何,感谢@JerryNixon 和@chuex 的帮助。

于 2013-01-24T01:09:11.340 回答