Udostępnij za pośrednictwem


How to: Check for ClickOnce Application Updates (Visual Basic)

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 Security and Deployment and Publishing ClickOnce Applications.

Example

This example uses the 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 using the Publish Wizard.

See Also

Tasks

How to: Download ClickOnce Application Updates (Visual Basic)

Reference

Deployment