2012-05-09 68 views
5

我有一個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仍正常工作。

+0

「在此階段,我無法在模擬器中運行應用程序時重現異常。」我知道在手機設置中禁用後臺代理時可能會拋出異常。我認爲在這種情況下,拋出'ScheduledActionService.Add'異常,而不是'ScheduledActionService.Find',但你應該試試看。 –

+0

當「後臺代理」按順序崩潰兩次時,它將從調度中刪除。也許有些例外是在這裏引起這種行爲... – 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,然後再次退出應用程序。 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,我發現Setting alarm in Windows Phone 7其中描述了在Application_Exit事件中調用ScheduleActionService時獲取相同的錯誤。

+0

我見過類似的崩潰堆棧: http://forums.create.msdn.com/forums/p/106202/625836.aspx#625836 –

相關問題