How to: Download ClickOnce Application Updates

This example uses the My.Application.Deployment object to download and install the latest version of an application. The example does not update the application unless it is out of date and was deployed as a ClickOnce application.

For more information on ClickOnce applications and how to deploy them, see ClickOnce Deployment and Publishing ClickOnce Applications.

Example

This example downloads and installs the update after using the My.Application.IsNetworkDeployed Property to make sure that the application is deployed using ClickOnce. The Update method does not update the application unless it is out of date. The application has to restart to use the update.

Sub UpdateApplication()
    If My.Application.IsNetworkDeployed Then
        My.Application.Deployment.Update()
    End If 
End Sub

This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Application—Compiling, Resources, and Settings. For more information, see How to: Insert Snippets Into Your Code (Visual Basic).

Only applications that are deployed using ClickOnce can be updated using the My.Application.Deployment object. For more information on deploying a ClickOnce application, see How to: Publish a ClickOnce Application.

See Also

Tasks

How to: Check for ClickOnce Application Updates

Reference

My.Application.Deployment Property