我有一个silverlight应用程序,用户可以安装out-of-browser。
右键查看更新面板时,设置为“检查更新,让我选择是否下载安装:
(来源:deviantsart.com)
但是,使用以下代码,我的应用程序会自动检测并下载新版本,并且新版本在应用程序下次启动时可用,无需任何用户交互:
应用程序.xaml.cs:
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new BaseApp();
if (Application.Current.IsRunningOutOfBrowser)
{
Application.Current.CheckAndDownloadUpdateAsync();
Application.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
}
}
void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
if (e.UpdateAvailable)
{
//an new version has been downloaded and silverlight version is the same
//so user just has to restart application
}
else if (e.Error != null &&
e.Error is PlatformNotSupportedException)
{
//a new version is available but the silverlight version has changed
//so user has to go to new website and install the appropriate silverlight version
}
else
{
//no update is available
}
}
这恰好是我想要的这个特定应用程序,但是:
这不是在误导用户吗,因为 Silverlight 播放器让他相信他将能够“选择是否下载和安装更新”,而实际上在他不知情的情况下下载和安装了更新?