ClickOnce Deployment (2) Automatic Updates

Source: Internet
Author: User

Last time we talked about how to deploy the application project in the most basic way with ClickOnce technology, let's take a look at how to make the application automatically updated.

We continue to learn through examples.

The first step is to build a random application project, as for the console, WPF or WinForm, we focus on publishing the application. Like this:

For a better demo, we can display the version number of the current publication on the window. I am a WinForm project here, so I use a Label control to display the current release version.

Note that the version number here is the version number of the ClickOnce publication, not the version number of the assembly. So to use the ApplicationDeployment class (located in the System.Deployment.Application namespace, in the Assembly System.Deployment.dll, if there is no reference, refer to it). Static property currentdeployment can be used to obtain a ApplicationDeployment object that is associated with the currently deployed application. You can then get the current version number from the ApplicationDeployment currentversion attribute. The code is as follows, as to where to write it, you think about it, this is a very basic thing.

Using System.Deployment.Application;
    
..... public partial class Form1:form
    
{public
    
Form1 ()
    
{
    
InitializeComponent ();
    
Gets the current deployment
    
applicationdeployment APPD = applicationdeployment.currentdeployment;
    
Gets the version number
    
This.lblVer.Text = appd. Currentversion.tostring ();
    
}
    

Okay, OK, now we can publish the application because we want it to be automatically updated, and we want to publish it to IIS or other servers, remember to run as admin vs, or not publish it, and to turn on the check-and-update feature, as mentioned in the previous section, the operation is simple.

In the Project Properties window, switch to the Publish tab, click the "Update ..." button to enable check updates, as to how to update, according to the default, there is no need to change.

Then make sure that it's configured well. Then publish to the server.

The second step is to enter the address through the browser, install and run the application, as shown in the following illustration, note that the current version is 1.0.0.0.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

The third step, closing the application, back to VS, we changed the program just to simulate the upgrade. For example, I add a button to the window, as shown below.

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.