Through the previous several learning and practice, I believe you can easily create personalized Silverlight out of the browser application. Last week, on the Silver China web forum, someone asked how to update the Silverlight out of browser application online. This article will address this issue and introduce how Silverlight's out of browser applications are updated online, and we will describe a new out of browser application installation that is provided in Silverlight 4.
First of all, Silverlight out of browser application online update
At the beginning of this series, we have introduced that the Silverlight out of browser and Silverlight Web applications are somewhat different, and the Silverlight Web updates the server-side XAP files after the user is loaded back into the The XAP file is automatically updated to the local temp directory. The automatic update applied by Silverlight out of browser is by calling the Checkanddownloadupdateasync method And application.checkanddownloadupdatecompleted, when the Updateavailable property is judged to be true, a new version has been discovered and successfully downloaded, on the contrary, false. If an exception is found in instrumentation, the exception instance information can be viewed through the error property.
In the usual way, we all update and detect when the application starts, so we need to add the code to the App.xaml constructor,
First create oncheckanddownloadupdatecompleted detect if a new version is allowed to download,
1 private void OnCheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
2 {
3 if (e.UpdateAvailable && e.Error == null)
4 {
5 MessageBox.Show(" 应用新版本已经下载成功,将在下次启动时生效。");
6 }
7 else if (e.Error != null)
8 {
9 MessageBox.Show("在 检测应用更新时, 在"
10 + "出现以下错误信 息:"
11 + Environment.NewLine
12 + Environment.NewLine
13 + e.Error.Message);
14 }
15 }