ClickOnce deployment (2): automatic update

Source: Internet
Author: User

Last time we talked about how to deploy an application project using ClickOnce Technology in the most basic way. In this article, we will learn how to enable automatic update for the application.

We still learn through instances.

Step 1: Create an application project on your own. Go to the console, WPF, or WinForm. We will focus on releasing applications. For example:

For better demonstration, we can display the current version number in the window. Here I am a WinForm project, so I will use a Label control to display the current version.

Note ,. Therefore, use the ApplicationDeployment class (located in the namespace of System. Deployment. Application, in the assembly System. Deployment. dll, if there is no reference, reference it ). The Static Property CurrentDeployment can be used to obtain an ApplicationDeployment object related to the currently deployed application. Then, you can obtain the current version number from the CurrentVersion attribute of ApplicationDeployment. The Code is as follows. As for where to write it, you can think about it as a basic task.

 

Okay, OK. Now we can release this application, because we want it to be automatically updated, and we will release it to IIS or other servers. In addition, to enable the update check function, as mentioned in the previous section, the operation is also very simple.

In the Project Properties window, switch to the release tab and click Update... "Button to enable Update check. As for how to update, you can do it by default, and there is no need to change it.

Then, make sure that the configuration is complete. And then publish it to the server.

 

Step 2: Enter the address in the browser to install and run the application, as shown in. Note that the current version is 1.0.0.0.

 

Step 3: Close the application and return to VS. Let's change the program to simulate the upgrade. For example, I add a button in the window, for example.

 

Step 4: Open

Click the "Publish now" button below.

 

Step 5: after the application is released successfully, run the application you just installed again from "start". The update prompt dialog box is displayed.

 

Click OK to automatically download and install the update. At this time, we can see that the version is 1.0.0.1.

Related Article

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.