Can finally realize the background Automatic Updates

Source: Internet
Author: User

I'm glad to hear that. Here are all the steps. The study was finally settled in the morning.

Step 1:build The application to update<?xml:namespace prefix = o ns = "Urn:schemas-microsoft-com:office:office"/ >

In here step we'll build the application to Auto-update.  If you are want, you can substitute the your own application here.  You can also use the pre-built sample application included in the Samples/sampleapp/sampleapp directory of the zip file. However for the purpose of proving that there isn ' t anything special about SampleApp, we'll walk through its creation.

1. Use Visual Studio. NET to create a new Windows application project, name it "SampleApp".

2. Give the form an interesting background color of your choice. We are using background color to differentiate between versions later.

3. Now let's add a tiny bit of functionality to this application in the form of a button that opens a form residing  In a separate assembly.   A button to your form.  The zip file contains an assembly and simple Windows Form in it.  ADD a reference to the Samples/sampleapp/simpleform assembly in the zip. Then add two lines of code to your button event handler:

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

F.show ();

4. Switch your build flag to builds release instead of Debug. This is allow us to avoid PDB file locking problems later when we build a new version of the application while the Origi NAL copy is still running.

5. Build and test your application. It should look similar to the Samples/sampleapp/sampleapp in the zip file.

Step 2:add the. NET Application Updater Component

In here step we'll add the. NET Application Updater component to SampleApp.

1. In the Components tab of the Visual Studio. NET Toolbox, right click and select ' Customize Toolbox '.  Select the '. NET Framework components ' tab.  Browse and select the AppUpdater.dll in the Appupdater project included in the zip. Click OK.

2. An appupdater icon, should now, is at the bottom of the the list of components in the Toolbox.  Drag and drop the Appupdater component onto the SampleApp Form. An AppUpdater1 instance of the. NET Application Updater component should is instantiated and appear the form.

Step 3:configure the. NET Application Updater Component

In here step we'll configure the. NET Application Updater component.  To doing this, select the AppUpdater1 component and open its properties.  The following section contains a description all property and what value to set it to. This is the "need to" change the "the" four properties for this example, for the rest, the defaults are adequate.

Appupdater Properties–these are the core Properties of the. NET Application Updater and'll need to is set for this app Lication as follows:

Property Name

Description

Autofileload

This controls the On-demand download feature described later.

Changedetectionmode

This enum determines the how to check for updates. In this example, we'll use a server manifest check and so set this value to "Servermanifestcheck".

Showdefaultui

The. NET Application Updater Component has a set of simple UI for notifying the user of events such as a new update Becomi  Ng available or errors during updates. This UI can is replaced with custom application specific UI by disabling the default UI, hooking the appropriate events (E  X. onupdatecomplete) and popping up the custom UI. For this example we'll use the default UI and so set this value to true.

UpdateUrl

The UpdateUrl is what determines where the updater looks for updates. In this case we are the using a server manifest to check for updates, so this property should is set to the URL of the server  Manifest.  For this example, set it to Http://yourWebserver/SampleApp_ServerSetup/UpdateVersion.xml. Replace ' YourWebServer ' with the name of your WEB server.


Downloader properties–the Appupdater component has two.  The downloader and controls the download and installation of the called. Below is a description of the properties, but all defaults'll work fine for our sampleapp.

Property Name

Description

Downloadretryattempts

If a failure occurs during download (ex The WEB server goes down) The downloader'll try again a little later. This property controls the number of times the downloader would retry the network request before treating it as a complete Application update failure.

Secondsbeteweendownloadrety

The number of seconds before retrying the network request.

Updateretryattempts

If a serious error occurs during the update process, (ex.  The downloader has exceeded the downloadretryattempts), a application update error is generated. By default, the update attempt'll stop, but'll attempt to resume "next time" the application is started (ex ... maybe T  He update Web server is just down for day.  This is controls how many the times an update would be attempted. If This value is exceeded, the updater aborts the update, resets its state and goes back to checking for updates.

Validateassemblies

This is controls the level of validation do on downloaded assemblies. Paper for more info.

Poller properties–the Second sub-component of the Appupdater is the poller.  The Poller controls the update checks. Below is a description of the properties, but all defaults'll work fine for our sampleapp.

Property Name

Description

AutoStart

A Boolean that controls whether or not the Poller should begin polling to updates on application startup or whether it sh Ould wait until the it is explicitly started programmatically.

Downloadondetection

A Boolean that controls whether or not the poller starts a download of ' an ' update immediately after a new update is found, or whether the download must is started explicitly by a call to the Downloadudpate () method.

Initialpollinterval

The number of seconds after application startup before the ' the ' the ' the ' the ' the '.

PollInterval

After the "The" I update check, the PollInterval controls the number of seconds between each subsequent update check. Note:by default this checks every seconds; Clearly you'll want to reduce the frequency for your application.

When you are said and done, your property grid should look the following:

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml"/>

The Samples/sampleapp/sampleapp_complete directory contains a version of the application correctly setup.

Step 4:build & Deploy V1 of the application to the client

In here step we'll build the V1 version of the application and deploy it to the client. The deployment is essentially simulating what the install program for your application'll do.

1. In the SampleApp project, open the AssemblyInfo.cs file.  Change the AssemblyVersion value from ' 1.0.* ' to ' 1.0.0.0 '. This would cause the built assembly to get marked with a value of "1.0.0.0" instead of the ever increasing value Visual Stu Dio normally assigns.

2. Build the application.

3. Copy the Samples/sampleapp/sampleapp_clientsetup directory from the zip onto your local machine. It doesn ' t matter where you copy it, however the program's files directory is the most realistic place to put it since  is where most applications get installed.  You'll notice that Sampleapp_clientsetup directory already has AppStart.exe included. Appstart.config is already set to point into the 1.0.0.0 directory and run SampleApp.exe.

4. Copy the complete SampleApp (Appupdater.dll, SimpleForm.dll & SampleApp.exe) from the release build director Y of SampleApp to the sampleapp_clientsetup/1.0.0.0 directory on your client.

At this point a fully functional version of the application should is "installed" on the client and executable by running AppStart.exe

Step 5:setup the WEB server

In here step we'll setup the WEB server for use in rolling out application updates. The. NET Application Updater component uses Http-dav to download the application update and thus requires a Web server tha  T supports Http-dav. IIS 5.0 that comes with Windows newer operating systems support.

1.

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.