PeriodicTaskバックグラウンドエージェントを介してLive Tileを更新するマーケットプレイスにWindows Phone 7アプリを導入しました。ScheduledActionService.Find throw ArgsException
1人のユーザーが、しばらくの間、タイルが更新されなくなってからの問題を報告しています。
電話機のバックグラウンドタスクをチェックすると、この機能は無効になり、「次回開くときにこのアプリケーションのバックグラウンドタスクをオンにする」チェックボックスがオンになります。
アプリを開いてピン操作をもう一度試みた後、バックグラウンドタスクは再開されませんでした。
私はこれは私がアプリのハブで見てきた2つのクラッシュレポートに関連している可能性が疑われる:Microsoft.Phone.Scheduler.ScheduledActionService.Findへ
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
コールは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.Findへ
コールがまだ正常に動作: - "アクションが無効に\ rをする\ nはあるBNSエラー"
のSystem.InvalidOperationException:私はScheduledActionService.Add(task);
から次の例外を取得します。
"この段階では、エミュレータでアプリを実行しているときに例外を再現できません。"携帯電話の設定でバックグラウンドエージェントが無効になっていると例外がスローされることがあることはわかっています。その場合、例外は 'ScheduledActionService.Find'ではなく' ScheduledActionService.Add'にスローされますが、試してみるべきです。 –
バックグラウンドエージェントが2回連続してクラッシュすると、スケジューリングから削除されます。たぶん、いくつかの例外がこの動作を引き起こすここにスローされます... – Ku6opr
@ Ku6opr、提案のおかげで。私はそれを試して、結果に質問を更新しました。それは原因ではないようです。 –