Bagikan melalui


How to: Check for ClickOnce Application Updates

This example uses the My.Application.Deployment object to check for available updates to the application. If the application was deployed as a ClickOnce application, the example displays appropriate user interface (UI) text.

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

Example

This example uses the My.Application.IsNetworkDeployed Property to make sure that the application is deployed from a network using ClickOnce. Then it uses the CheckForUpdate method of the My.Application.Deployment object to check if a ClickOnce update is available for the application.

Sub CheckUpdateAvailability()
    If My.Application.IsNetworkDeployed() Then 
        If My.Application.Deployment.CheckForUpdate() Then
            MsgBox("Update is available for download")
        Else
            MsgBox("No updates are available for download")
        End If 
    Else
        MsgBox("Application is not ClickOnce deployed")
    End If 
End Sub

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: Download ClickOnce Application Updates

Reference

My.Application.Deployment Property