. NET client application:. NET application Update component (5)

Source: Internet
Author: User
Tags modify
Program | Client limited to space reasons, as follows only the translation


(connected with the article)





we discussed it before. NET application update, now we're going to apply it to the instance.





First step: Build an application to update





in this step we will build an application to demonstrate how to implement Automatic Updates.





1. Use Vs.net to build a new Windows Application project named "SampleApp".





2. Give the form an interesting background color that you choose. We will use the background color to distinguish it from the version that is later updated.





3. Now let's add a little feature to the application and add a button to your form first. The compressed file contains an assembly that has a simple Windows Form. Adds a reference to the Samples\sampleapp\simpleform assembly in the compressed file. Then add two lines of code to your button event handle:





Simpleform.form1 F = new Simpleform.form1 ();





f.show ();





4. Convert your build flag from debug to release. This will allow us to avoid later when we build a new version of the application while the original copy is running and the PDB file lock problem is generated.





Build and test your application.





Step Two: Add. NET Application Update component





In this step, we will add the. NET application update component to SampleApp.





1. On the Component tab of the Vs.net toolbar, right-click to select Customize toolbar. Select '. NET Framework Components tab. Click Browse and select the AppUpdater.dll under the Appupdater item in the compressed file.





2. A appupdater icon should now appear at the bottom of the list of components in the toolbar. Drag and drop the Appupdater component onto the SampleApp form. An instance of the. NET application update component named AppUpdater1 appears at the bottom of the form.





Third step: Set up. NET Application Update component





in this step we will set. NET application update component. Note that this example you only need to change the first four attributes, the other, the default value is enough.





Appupdater Properties-This is the core of the. NET application application update, and the following settings are required for this program:











Property name


Description





Autofileload


the command download feature to be described later in this control, set it to true now.





Changedetectionmode








This enumeration determines how to check for updates. In this example, we will use a server for explicit checking, so set this value to "Servermanifestcheck".





Showdefaultui








. NET application update component has a series of user interfaces to notify users of events, and for this example we will use the default user interface, so set this value to true.





UpdateUrl








UpdateUrl is where the updates are determined to find updates. In this example, set the URL for the server's explicit file:





Http://yourWebserver/SampleApp_ServerSetup/UpdateVersion.xml.





Use your Web server name instead of "YourWebServer"













The
Downloader Property ――appupdater component has two subcomponents. The first is called Downloader, which controls the download and installation of components. The following is a description of the property, and the default property value for my example works fine.





Property name


Description





downloadretryattempts








If any errors occur during the download (such as Web server downtime) Downloader will try again later. This property controls the number of times a network request was retried before Downloader considered a thorough application update error.





secondsbeteweendownloadrety


the number of seconds to wait before retrying the network request.





updateretryattempts


This property controls the number of attempts to update.





validateassemblies








This property controls the level at which the download assembly is effectively completed. See the Security section of this article for more information.













The second subassembly of the
Poller property ――appupdater is Poller. Poller Control Update check. The following is a description of the property, and for our example, all the default property values work fine.





Property name


Description





AutoStart








Boolean value that controls whether the Poller should start polling or whether it should wait until a scheduled explicit start is made at application startup.





Downloadondetection


Boolean value that controls whether the Poller immediately starts downloading updates when a new update is found, or whether an explicit download must begin by calling the Downloadudpate () method.





Initialpollinterval


the number of seconds that the application waits before it first performs an update check.





PollInterval








after the first update check, PollInterval controls the number of seconds between each subsequent update check, note: The default is to check every 30 seconds.














after all this has been done, your property table should look like this:













The
Samples\sampleapp\sampleapp_complete directory contains a version that the application correctly installs.





Step Fourth: Build and deploy the application V1 version on the client.





in this step we will build the application V1 version and deploy it to the client.





in the SampleApp project, open the AssemblyInfo.cs file. Modify the value of the AssemblyVersion from "1.0" to "1.0.0.0". This causes a tag that has a value of "1.0.0.0" to be generated when the assembly is built, instead of vs.net, which is usually specified as an incremented value.





1. Build the application.





2. Copy the Samples\sampleapp\sampleapp_clientsetup directory from the compressed file to your local machine. Be aware that the Sampleapp_clientsetup directory already contains AppStart.exe. Appstart.config has been set to point to the 1.0.0.0 directory and start SampleApp.exe.





copy SampleApp (Appupdater.dll,simpleform.dll and SampleApp.exe) from SampleApp's release generation directory to your client's Sampleapp_clientsetup The \1.0.0.0 directory.





at this time, a fully functional version of the application should be "installed" to the client, which can be executed by running AppStart.exe.





Step Fifth: Install the Web server





in this step we will install the Web server to use when polling application updates ... NET application update component uses HTTP-DAV to download application updates and therefore requires a Web server that supports Http-dav. Http-dav is supported for both IIS5.0 and newer operating systems on Windows 2000.





1. Copy the Samples/sampleapp_serversetup directory from the compressed file to the Wwwroot directory on your Web server.





2. To complete, copy the V1 version of SampleApp to the 1.0.0.0 folder of the Web server.





3. On your Web server, enable IIS directory browsing for the Sampleapp_serversetup directory.





Step Sixth: Automatically update applications





OK, now is the time to install a new version by automatically looking at the results of these hard work.





1. If you deploy a SampleApp version of the client that is not running, load it to let it run. Remember to use AppStart.exe.





2. Go back to vs.net and make some noticeable changes in the SampleApp form (such as modifying the background color).





3. Modify the AssemblyInfo.cs version information to 2.0.0.0.





4. Regenerated.





5. Return to the Web server and generate a directory equivalent to the 1.0.0.0 directory 2.0.0.0. Copy the new version of the application from the release generation directory to the new 2.0.0.0 directory on the Web server.





6. Open Updateversion.xml and modify availableversion to 2.0.0.0. Modify ApplicationUrl to point to the new 2.0.0.0 path.





7. Save the changes you made to Updateversion.xml.





Once you save the new updateversion.xml, within 30 seconds, the SampleApp copy in the run will detect the new version available. SampleApp will download the new version, implement the update, and pop up the default user interface to ask the user if they want to reboot and start using the new version immediately. Click Yes to return to the dialog box. SampleApp will reboot and run the new version. If you look at the deployment of client-side SampleApp, you will notice that there is now a 2.0.0.0 directory behind the original 1.0.0.0 directory. The 1.0.0.0 directory will be emptied when the next update occurs.





(to be continued)











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.