ApplicationDeployment.CheckForDetailedUpdate Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Performs the same operation as CheckForUpdate, but returns extended information about the available update.

Namespace:   System.Deployment.Application
Assembly:  System.Deployment (in System.Deployment.dll)

public UpdateCheckInfo CheckForDetailedUpdate()

Return Value

Type: System.Deployment.Application.UpdateCheckInfo

An UpdateCheckInfo for the available update.

Exception Condition
InvalidOperationException

The current application is either not configured to support updates, or there is another update check operation already in progress.

DeploymentDownloadException

The deployment manifest cannot be downloaded. This exception will appear in the Error property of the CheckForUpdateCompleted event.

InvalidDeploymentException

The deployment manifest is corrupted. Regenerate the application's manifest before you attempt to deploy this application to users. This exception will appear in the Error property of the CheckForUpdateCompleted event.

The CheckForDetailedUpdate method lets synchronous callers get the same extended information that asynchronous callers get using the CheckForUpdateCompletedEventArgs class.

The following code example uses CheckForDetailedUpdate to retrieve the information about the latest update. If an update exists, it installs it automatically only if it is a required update; otherwise, it prompts the user.

public void LaunchAppUpdate()
{
    if (ApplicationDeployment.IsNetworkDeployed)
    {
        ApplicationDeployment appDeploy = ApplicationDeployment.CurrentDeployment;
        appDeploy.UpdateCompleted += new AsyncCompletedEventHandler(appDeploy_UpdateCompleted);
    }
}

void appDeploy_UpdateCompleted(object sender, AsyncCompletedEventArgs e)
{
    if (e.Error != null)
    {
        MessageBox.Show("Could not install application update. Please try again later,  or contact a system administrator.", "Application Update Error");
        return;
    }
    else if (e.Cancelled)
    {
        MessageBox.Show("The application update has been cancelled.", "Application Update Cancelled");
        return;
    }

    // Process successful update.
    DialogResult dr = MessageBox.Show("The application has been updated. Restart?", "Restart Application", MessageBoxButtons.OKCancel);
    if (DialogResult.OK == dr)
    {
        Application.Restart();
    }
}

PermissionSet

For full access to the local computer. Associated enumeration: PermissionState.

.NET Framework
Available since 2.0
Return to top
Show: