I have a Windows Phone 7 app deployed in the marketplace that updates its Live Tile via a PeriodicTask Background Agent.
One user is reporting issues with the tile no
I managed to reproduce the ArgumentException and StackTrace in the emulator and on a handset attached to my PC.
The steps were:
ScheduledActionService.Find(TASK_NAME)
ScheduledActionService.LaunchForTest(TASK_NAME, new TimeSpan(0, 0, 1));
immediately after adding the PeriodicTask.SetupApplicationBar()
, which ultimately calls the ScheduledActionService.Find()
method.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)
Given that the app is shutting down and I'm only trying to figure out if the background agent is running I figure it is safe to catch the exception and return false from my TaskIsActive()
method.
Now that I know the message from the ArgumentException is E_INVALIDARG I found Setting alarm in Windows Phone 7 which describes getting the same error when making calls to ScheduleActionService in the Application_Exit event.