Special cases where the Silverlight 5 OOB application cannot be updated normally

Source: Internet
Author: User

Previously, a OOB application for Silverlight 5 was developed.ProgramBut there is a special situation in update.

OOB application update Method

The Silverlight application hosted in the browser can be automatically updated, but the OOB application may be in a safe state, but the rate cannot be automatically updated. You need to call a method to check for updates to manually execute updates.

First, register a handler for the checkanddownloadupdatecompleted event of the application, as shown below:

 
_ APP = application. Current;If(_ App. isrunningoutofbrowser) _ app. checkanddownloadupdatecompleted + = application_checkanddownloadupdatecompleted;

Then, create an update button and click the button to add the updatedCode, As follows:

  private   void  button#click ( Object  sender, routedeventargs e) { If  (_ app. isrunningoutofbrowser & networkinterface. getisnetworkavailable () _ app. checkanddownloadupdateasync () ;}

Of course, the above Code can also be put into the page loading event, so that the program will automatically check for updates each time it starts, but the best practice is to create a set of automatic version check mechanisms, then, the user is prompted to have an update and then run the above Code.

Finally, it is to write the processing code after the update is completed, as follows:

  void  application_checkanddownloadupdatecompleted ( Object  sender, checkanddownloadupdatecompletedeventargs e) { If  (E. error! =  null ) { If  (E. error  is  platformnotsupportedexception) MessageBox. show ( "app_needupgradeplatform" );  else  MessageBox. show ( "app_upgradeerror:"  + E. error. message);  return ;}< SPAN class = "kwrd"> If  (E. updateavailable) MessageBox. show ( "app_upgradecompleted" );  else  MessageBox. show ( "app_noupdate" ) ;}

This is the basic method for updating OOB applications.

OOB application updates after improved Trust

The msdn document provides a special description of OOB application updates after the trust is improved, as follows:

Silverlight 4 provides support for running out-of-browser applications with improved Trust. Trusted applications cannot use the update mechanism described in this section unless the application and update use the same valid code signature certificate for signature. To update a trusted application without a valid signature, you must uninstall the old version and manually install the new version. For more information, see trusted applications.

The meaning of this sentence is that if different signature files are used before and after the update, or the old version does not have a signature, the new version will be signed, which will cause the update to fail, you need to uninstall and reinstall it.

That is, this sentence misled me for half a day.

Special situations that cannot be updated

The OOB application I developed can be updated at the beginning, but I don't know why it cannot be updated. I searched for various reasons, tried various methods, and speculated on various situations.

Finally, I independently set up a test project to compare and test the project. When all the configurations and code are the same, the project can be updated, so that I can begin to consider whether the Silverlight SDK has a problem. After comparing the files of the entire project, it is found that the test project is one file fewer than the official project-inbrowsersettings. xml. This file is actually a new feature provided by Silverlight 5, that is, a configuration file generated by the enhance trust function in the browser.

This file is generated when I try to select the "enhance the trust in the browser" option, so I deleted the configuration file inbrowsersettings. xml. The problem persists, but it seems that the problem is approaching. Some configuration information is also recorded in csproj. Therefore, when you open the csproj file, you find that there are inbrowsersettingsfile and requireinbrowserelevation nodes. After you delete these two nodes, after testing, the update is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.