我想知道如何设置我的Silverlight项目以启用离线应用程序的自动更新。
我在app.xaml.cs中添加了一些代码(见下文),重新构建了应用程序,安装为离线应用程序,在assemblyinfo.cs中更改了versioninfo,重新编译,再次运行,但不幸的是没有更新发生。我还有什么遗漏吗?
我在app.xaml.cs中添加了一些代码(见下文),重新构建了应用程序,安装为离线应用程序,在assemblyinfo.cs中更改了versioninfo,重新编译,再次运行,但不幸的是没有更新发生。我还有什么遗漏吗?
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
if (Application.Current.IsRunningOutOfBrowser)
{
App.Current.CheckAndDownloadUpdateCompleted +=
new CheckAndDownloadUpdateCompletedEventHandler(App_CheckAndDownloadUpdateCompleted);
App.Current.CheckAndDownloadUpdateAsync();
}
}
void App_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
if (e.Error == null && e.UpdateAvailable)
{
MessageBox.Show("Application updated, please restart to apply changes.");
}
}
编辑
额外问题:
应用程序如何检测是否有更新?从assemblyinfo.cs文件中?还是在清单中的某个位置?
编辑
有人能解释一下为什么IsRunningOutOfBrowser
即使从桌面快捷方式运行应用程序也始终返回FALSE吗?