我有一個Windows Phone 7應用程序部署在市場上,通過PeriodicTask後臺代理更新其活動瓷磚。ScheduledActionService.Find拋出ArgumentException
一個用戶正在報告問題,該問題在其工作一段時間後不再更新。
當他們檢查手機上的後臺任務時,它被禁用,並且複選框爲「下次打開它時爲此應用程序重新打開後臺任務」被選中。
打開應用程序並再次嘗試引腳操作後,後臺任務尚未恢復。
我懷疑這可能與兩個碰撞報告,我已經在應用程序中心看到:
Problem Function: Microsoft.Phone.Scheduler.SystemNotificationInterop.CheckHr
Exception Type: ArgumentException
Stack Trace:
Frame Image Function Offset
0 coredll.dll xxx_RaiseException 19
1 mscoree3_7.dll WatsonUnhandledManagedException 296
2 mscoree3_7.dll Dbg_NotifyManagedException 93
3 mscoree3_7.dll FirstPassException 1044
4 TransitionStub 0
5 Microsoft.Phone.Scheduler.SystemNotificationInterop.CheckHr 248
6 Microsoft.Phone.Scheduler.SystemNotificationInterop.GetNotificationByID 156
7 Microsoft.Phone.Scheduler.ScheduledActionService.Find 276
8 MyApp.Agents.TaskIsActive 60
9 MyApp.MainPage.SetupApplicationBar 44
10 MyApp.MainPage.MainPage_Loaded 100
11 MS.Internal.CoreInvokeHandler.InvokeEventHandler 3660
12 MS.Internal.JoltHelper.FireEvent 1348
13 mscoree3_7.dll IL_CallManaged 884
14 mscoree3_7.dll IL_CallDelegateInternal 176
15 mscoree3_7.dll makeComPlusCall 5255
16 mscoree3_7.dll makeComPlusCallReturnInt 21
17 0
18 agcore.dll CCoreServices::CLR_FireEvent 385
呼叫至Microsoft.Phone.Scheduler.ScheduledActionService.Find正導致一個ArgumentException。
我正在調用Find方法的名稱參數來自private const string
,因此每個調用的值都是相同的。
我應該只是捕捉到這個異常,並假設後臺代理不存在或它是否表示代理有問題?
在此階段,我無法在模擬器中運行應用程序時重現異常。
"When [the] Background Agent crashes two times in sequence, it's removed from scheduling"
我試着故意撞毀每次調用的ScheduledAgent如下:
protected override void OnInvoke(ScheduledTask task)
{
UpdateTile();
#if DEBUG
// If we're debugging, fire the task again
ScheduledActionService.LaunchForTest("MyScheduledTaskAgent", new TimeSpan(0, 0, 30));
throw new Exception("Bang");
#endif
NotifyComplete();
}
這確實會導致後臺任務,以兩個調用後下的設置中關閉在模擬器。但是,如果我重新打開對ScheduledActionService.Find工作的應用程序調用而沒有異常。我也可以刪除失敗的PeriodicTask並添加一個沒有問題的新實例。
"an exception can be thrown when the background agent is deactivated in the phone's settings. I think in that case the exception is thrown on ScheduledActionService.Add, not ScheduledActionService.Find"
我在模擬器中嘗試這個。我從ScheduledActionService.Add(task);
出現以下情況例外:
System.InvalidOperationException - 「BNS錯誤:將不起任何作用\ r \ n」 個
呼叫至ScheduledActionService.Find仍正常工作。
「在此階段,我無法在模擬器中運行應用程序時重現異常。」我知道在手機設置中禁用後臺代理時可能會拋出異常。我認爲在這種情況下,拋出'ScheduledActionService.Add'異常,而不是'ScheduledActionService.Find',但你應該試試看。 –
當「後臺代理」按順序崩潰兩次時,它將從調度中刪除。也許有些例外是在這裏引起這種行爲... – Ku6opr
@ Ku6opr,感謝您的建議。我試過了,並用結果更新了問題。它似乎不是原因。 –