ApplicationDeployment.CheckForUpdate Method
Assembly: System.Deployment (in system.deployment.dll)
'Declaration Public Function CheckForUpdate As Boolean 'Usage Dim instance As ApplicationDeployment Dim returnValue As Boolean returnValue = instance.CheckForUpdate
public boolean CheckForUpdate ()
public function CheckForUpdate () : boolean
Not applicable.
Return Value
true if a new update is available; otherwise, false.The CheckForUpdate method compares the version of the currently installed deployment with the version specified in the deployment manifest found at UpdateLocation. If the version on the server is different from the installed version, it returns true.
This method will block until the check has completed. To check for an update asynchronously, use the CheckForUpdateAsync method instead.
Note: |
|---|
| If CheckForUpdate discovers that an update is available, and the user chooses not to install it, ClickOnce will prompt the user that an update is available the next time the application is run. There is no way to disable this prompting. (If the application is a required update, ClickOnce will install it without prompting.) |
The following code example checks for an application update; if one is available, it installs it synchronously.
Private Sub InstallUpdateSync() If (ApplicationDeployment.IsNetworkDeployed) Then Dim updateAvailable As Boolean = False Dim AD As ApplicationDeployment = ApplicationDeployment.CurrentDeployment Try updateAvailable = AD.CheckForUpdate() Catch dde As DeploymentDownloadException ' This exception occurs if a network error or disk error occurs ' when downloading the deployment. MessageBox.Show("The application cannot check for the existence of a new version at this time. " + ControlChars.Lf + ControlChars.Lf + "Please check your network connection, or try again later. Message: " + dde.Message) Exit Sub Catch ide As InvalidDeploymentException MessageBox.Show("The application cannot check for an update. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Message: " + ide.Message) Exit Sub Catch ioe As InvalidOperationException MessageBox.Show("The application cannot check for an update. This most likely happened because the application is already updating. Message: " + ioe.Message) Exit Sub End Try If (updateAvailable) Then Try AD.Update() MessageBox.Show("The application has been upgraded, and will now restart.") Application.Restart() Catch dde As DeploymentDownloadException MessageBox.Show("Cannot install the latest version of the application. " + ControlChars.Lf + ControlChars.Lf + "Please check your network connection, or try again later.") End Try End If End If End Sub
- PermissionSet For full access to the local computer. Associated enumeration: PermissionState.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Note: