我有一个 Windows Phone 市场应用程序。用户报告说应用程序有时会在 Windows Phone 8 上崩溃。这是我来自 Windows Phone 开发中心报告的数据:
问题功能:
Microsoft.Phone.Scheduler.SystemNotificationInterop.CheckHr
异常类型
system.reflection.targetinvocationexception
堆栈跟踪:
Frame Image Function Offset
0 microsoft_phone_ni Microsoft.Phone.Scheduler.SystemNotificationInterop.CheckHr 0x0000019a
1 microsoft_phone_ni Microsoft.Phone.Scheduler.SystemNotificationInterop.CreateNotification 0x0000002e
2 microsoft_phone_ni Microsoft.Phone.Scheduler.ScheduledActionService.Add 0x00000056
3 myapp_ni Myapp.MainPage..ctor 0x000000b0
问题可能出在后台代理上。我用过这些教程。
我的代码:
public MainPage()
{
InitializeComponent();
/* Periodic agents*/
// A unique name for your task. It is used to
// locate it in from the service.
var taskName = "MyTask";
// If the task exists
var oldTask = ScheduledActionService.Find(taskName) as PeriodicTask;
if (oldTask != null)
{
ScheduledActionService.Remove(taskName);
}
// Create the Task
PeriodicTask task = new PeriodicTask(taskName);
// Description is required
task.Description = "This saves some data to Isolated Storage";
// Add it to the service to execute
ScheduledActionService.Add(task);
/* Testing my agent*/
// ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromMilliseconds(1500));
/* Testing my agent*/
/* Periodic agents */
...
我阅读了ScheduledActionService.Find throws ArgumentException,但不知道背后的想法