我有一个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
问题可能出在后台代理上。我使用过these tutorial。
我的代码:
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,但背后没有想法
答案 0 :(得分:0)
您必须将定期代理代码放在Application_Closing