我没有使用后台代理来更新 LiveTiles。我在退出应用程序时更新磁贴并在Application_Deactivated
.
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
CycleManager pCycMan = CycleManager.Instance;
pCycMan.WriteToIsolatedStorage();
ResourceManager resMan = new ResourceManager("xxx.AppResources", Assembly.GetExecutingAssembly());
ShellTile PrimaryTile = ShellTile.ActiveTiles.First();
StandardTileData tile = new StandardTileData();
try
{
if (PrimaryTile != null)
{
tile.BackTitle = resMan.GetString("liveTileTitle");
tile.BackBackgroundImage = new Uri("/Background.png", UriKind.Relative);
if (pCycMan.GetStartDate() == pCycMan.GetDefaultDate())
{
tile.Title = resMan.GetString("liveTileNotTrackingStatus");
}
else
{
tile.Title = m_liveTileText;
}
PrimaryTile.Update(tile);
}
}
catch(Exception)
{
}
}
这样做是一个好习惯吗?该应用程序已发布,并且我收到了带有 COMException 的 StackTrace。它表明在执行Microsoft.Phone.Shell.ShellTile.Update
之后引发了异常XXX.App.Application_Deactivated
有谁知道这个例外或面临这种情况?如果有人可以指导我这将非常有帮助。