ApplicationDeployment.CheckForDetailedUpdate Method

Definition

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

Overloads

CheckForDetailedUpdate()

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

CheckForDetailedUpdate(Boolean)

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

CheckForDetailedUpdate()

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

public:
 System::Deployment::Application::UpdateCheckInfo ^ CheckForDetailedUpdate();
public System.Deployment.Application.UpdateCheckInfo CheckForDetailedUpdate ();
member this.CheckForDetailedUpdate : unit -> System.Deployment.Application.UpdateCheckInfo
Public Function CheckForDetailedUpdate () As UpdateCheckInfo

Returns

An UpdateCheckInfo for the available update.

Exceptions

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

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

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.

Examples

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 InstallUpdateSyncWithInfo()
    {
        if (ApplicationDeployment::IsNetworkDeployed)
        {
            ApplicationDeployment^ deployment =
                ApplicationDeployment::CurrentDeployment;
            UpdateCheckInfo^ updateInfo = nullptr;

            try
            {
                updateInfo = deployment->CheckForDetailedUpdate();
            }
            catch (Exception^ ex)
            {
                MessageBox::Show("The update failed. Error: {0}",
                    ex->Message);
                return;
            }

            if (updateInfo->UpdateAvailable)
            {
                bool doUpdate = true;

                if (!updateInfo->IsUpdateRequired)
                {
                    System::Windows::Forms::DialogResult dr =
                        MessageBox::Show(
                        "An update is available. Would you like to " +
                        "update the application now?",
                        "Update Available",
                        MessageBoxButtons::OKCancel);
                    if (!(System::Windows::Forms::DialogResult::OK == dr))
                    {
                        doUpdate = false;
                    }
                }

                if (doUpdate)
                {
                    try
                    {
                        deployment->Update();
                        MessageBox::Show(
                            "The application has been upgraded, and will " +
                            "now restart.");
                        Application::Restart();
                    }
                    catch (Exception^ ex)
                    {
                        MessageBox::Show("The update failed. Error: {0}",
                            ex->Message);
                        return;
                    }
                }
            }
        }
    }
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();
    }
}
Dim WithEvents ADLaunchAppUpdate As ApplicationDeployment

Public Sub LaunchAppUpdate()
    If (ApplicationDeployment.IsNetworkDeployed) Then
        ADLaunchAppUpdate = ApplicationDeployment.CurrentDeployment
    End If
End Sub


Private Sub ADLaunchAppUpdate_UpdateCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs) Handles ADLaunchAppUpdate.UpdateCompleted
    If Not (e.Error Is Nothing) Then
        MessageBox.Show("Could not install application update. Please try again later,  or contact a system administrator.", "Application Update Error")
        Exit Sub
    Else
        If (e.Cancelled) Then
            MessageBox.Show("The application update has been cancelled.", "Application Update Cancelled")
            Exit Sub
        End If
    End If

    ' Process successful update.
    Dim dr As DialogResult = MessageBox.Show("The application has been updated. Restart?", "Restart Application", MessageBoxButtons.OKCancel)
    If (System.Windows.Forms.DialogResult.OK = dr) Then
        Application.Restart()
    End If
End Sub

Remarks

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

Applies to

CheckForDetailedUpdate(Boolean)

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

public:
 System::Deployment::Application::UpdateCheckInfo ^ CheckForDetailedUpdate(bool persistUpdateCheckResult);
public System.Deployment.Application.UpdateCheckInfo CheckForDetailedUpdate (bool persistUpdateCheckResult);
member this.CheckForDetailedUpdate : bool -> System.Deployment.Application.UpdateCheckInfo
Public Function CheckForDetailedUpdate (persistUpdateCheckResult As Boolean) As UpdateCheckInfo

Parameters

persistUpdateCheckResult
Boolean

If false, the update will be applied silently and no dialog box will be displayed.

Returns

An UpdateCheckInfo for the available update.

Applies to