2012-05-09 4 views
5

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);から次の例外を取得します。

+0

"この段階では、エミュレータでアプリを実行しているときに例外を再現できません。"携帯電話の設定でバックグラウンドエージェントが無効になっていると例外がスローされることがあることはわかっています。その場合、例外は 'ScheduledActionService.Find'ではなく' ScheduledActionService.Add'にスローされますが、試してみるべきです。 –

+0

バックグラウンドエージェントが2回連続してクラッシュすると、スケジューリングから削除されます。たぶん、いくつかの例外がこの動作を引き起こすここにスローされます... – Ku6opr

+0

@ Ku6opr、提案のおかげで。私はそれを試して、結果に質問を更新しました。それは原因ではないようです。 –

答えて

1

エミュレータと私のPCに接続されたハンドセットで、ArgumentExceptionとStackTraceを再現することができました。

の手順は以下の通りであった。

  1. ScheduledActionService.Find(TASK_NAME)
  2. への呼び出しの周りの例外ハンドラでのブレークポイントが
  3. 利用添付デバッガとエミュレータ(またはハンドセット)でアプリを起動し設定しますピンメニュー項目を使用して、PeriodicTaskバックグラウンドエージェントを開始します。デバッグモードでは、PeriodicTaskを追加した直後にScheduledActionService.LaunchForTest(TASK_NAME, new TimeSpan(0, 0, 1));を呼び出します。
  4. アプリ内のサブページに移動します。
  5. すぐに戻るボタンを使用してメインページに戻り、もう一度アプリケーションを終了します。 MainPageのLoadedイベントはSetupApplicationBar()を呼び出し、最終的にScheduledActionService.Find()メソッドを呼び出します。
  6. アプリケーションがシャットダウンする際に例外が発生します。

Exception Type: ArgumentException

Message: E_INVALIDARG

StackTrace:

at Microsoft.Phone.Scheduler.SystemNotificationInterop.CheckHr(Int32 hr)
at Microsoft.Phone.Scheduler.SystemNotificationInterop.GetNotificationByID(Guid notificationID)
at Microsoft.Phone.Scheduler.ScheduledActionService.Find(String name)
at SolarCalculator.Agents.TaskIsActive()
at SolarCalculator.MainPage.SetupApplicationBar()
at SolarCalculator.MainPage.MainPage_Loaded(Object sender, RoutedEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

はアプリがシャットダウンしていることを考えると、私は唯一のバックグラウンドエージェントが、私は例外をキャッチし、私のTaskIsActive()メソッドからfalseを返すことは安全である把握実行されているかどうかを把握しようとしています。

ArgumentExceptionからのメッセージがE_INVALIDARGであることがわかったので、Application_ExitイベントでScheduleActionServiceを呼び出すときに同じエラーが発生することが記述されているSetting alarm in Windows Phone 7が見つかりました。

+0

私は、同様のクラッシュスタックを見ました: http://forums.create.msdn.com/forums/p/106202/625836.aspx#625836 –