Check and update the latest version in OOB mode.

Source: Internet
Author: User

1. cause:

Because there are more or less problems with such articles on the internet, I came up with the idea of writing a blog post.

2. What happened?

I found several articles on the Internet and tried them several times before they all ended in failure. Finally, we decided to find the cause.

3. Investigate the causes

Dig into the following code and find that the initializecomponent method uses the loadcomponent method of the application class to create an app file instance.
In this case, the problem is explained as follows:Why can I check the version and application information if no object is created in the app?

The excerpt code is as follows:

public App(){     if (App.Current.InstallState == InstallState.Installed)     {         App.Current.CheckAndDownloadUpdateCompleted += (sender,e)=>{};         App.Current.CheckAndDownloadUpdateAsync();     }     this.Startup += this.Application_Startup;     this.Exit += this.Application_Exit;     this.UnhandledException += this.Application_UnhandledException;     InitializeComponent();}

4. Solve the Problem

Move the update detection step to the application_startup event and check for updates when the application starts.

Private void application_startup (Object sender, startupeventargs E)
{
If (App. Current. installstate = installstate. installed)
{
This. checkanddownloadupdatecompleted + = (SMEs, EMEs) =>
{
If (EMEs. updateavailable)
{
MessageBox. Show ("successful ")
}
Else if (EMEs. Error! = NULL & EMEs. error is platformnotsupportedexception)
{
MessageBox. Show ("not successful ");
}
};
This. checkanddownloadupdateasync ();
}
}

5. Exploring the essence

The first question is how to open an application in OOB mode.

When the application is installed locally in the browser, a shortcut file is automatically generated.

Open the file Properties window and you will find the following line in the target line:

"C: \ Program Files \ microsoft Silverlight \ sllauncher.exe" 3687885092. localhost

When I try to open sllauncher.exe, the following prompt box is displayed:

This means that I need to pass some parameters to this application to continue.

How does sllauncher.exe work?

After searching, I finally found the path for storing apps outside the browser:

C: \ Users \ Administrator \ appdata \ Local \ Microsoft \ Silverlight \ outofbrowser

The folder 3687885092. localhost exists and the following files exist:

The logic of the sllauncher.exe file is actually to search for a folder in the outofbrowser folder that matches the parameters passed in the shortcut, and then call the local Win32 function to pop up the window and load the xap file.

The second question: How can I detect and update the latest version.

In this experiment, we install three applications:

The first installation of the application will produce the following figure:

After the program code is changed, the second installation of the application will produce the following figure:

After the program code is changed again, the third installation of the application will produce the following figure:

Through the comparison of the three images, you can clearly see the general idea of Microsoft updating OOB:

(1)the first update will create update.html, reference the latest update. xap, and modify the state file to record some information.

(2nd) the second update, repeat the first step, but replace the most newly created application.xapwith and index.html with the first update file.

(3) version iterations

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.