CheckForUpdateCompletedEventArgs.MinimumRequiredVersion Propriété

Définition

Obtient la version minimale que l'utilisateur doit avoir installée sur l'ordinateur.

public:
 property Version ^ MinimumRequiredVersion { Version ^ get(); };
public Version MinimumRequiredVersion { get; }
member this.MinimumRequiredVersion : Version
Public ReadOnly Property MinimumRequiredVersion As Version

Valeur de propriété

Version

Objet Version exprimant la version la plus ancienne que tous les utilisateurs doivent installer.

Exemples

L’exemple de code suivant appelle CheckForUpdateAsync et force une mise à jour d’application si MinimumRequiredVersion est supérieur à CurrentVersion .

ApplicationDeployment adCheckForUpdateAsyncMin;

private void CheckForUpdateAsyncMin()
{
    if (ApplicationDeployment.IsNetworkDeployed)
    {
        adCheckForUpdateAsyncMin = ApplicationDeployment.CurrentDeployment;
        adCheckForUpdateAsyncMin.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(adCheckForUpdateAsyncMin_CheckForUpdateCompleted);

        adCheckForUpdateAsyncMin.CheckForUpdate();
    }
}

void adCheckForUpdateAsyncMin_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs 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;
    }

    adCheckForUpdateAsyncMin = ApplicationDeployment.CurrentDeployment;
    if (e.MinimumRequiredVersion > adCheckForUpdateAsyncMin.CurrentVersion)
    {
        // Launch an install of the minimum required version. 
        adCheckForUpdateAsyncMin.UpdateCompleted += new AsyncCompletedEventHandler(adCheckForUpdateAsyncMin_UpdateCompleted);
        adCheckForUpdateAsyncMin.UpdateAsync();
    }
}

void adCheckForUpdateAsyncMin_UpdateCompleted(object sender, AsyncCompletedEventArgs e)
{
    // Alert user that update is complete.
    if (e.Error != null)
    {
        MessageBox.Show("Could not install application update. We will try and upgrade the application later.", "Application Update Error");
        return;
    }
    else if (e.Cancelled)
    {
        MessageBox.Show("The application update has been cancelled.", "Application Update Cancelled");
        return;
    }

    MessageBox.Show("The update was successful. Your application will now be restarted.", "Restart Application");
    Application.Restart();
}
Dim WithEvents ADCheckForUpdateAsyncMin As ApplicationDeployment

Private Sub CheckForUpdateAsyncMin()
    If (ApplicationDeployment.IsNetworkDeployed) Then
        ADCheckForUpdateAsyncMin = ApplicationDeployment.CurrentDeployment

        ADCheckForUpdateAsyncMin.CheckForUpdate()
    End If
End Sub


Private Sub ADCheckForUpdateAsyncMin_CheckForUpdateCompleted(ByVal sender As Object, ByVal e As CheckForUpdateCompletedEventArgs) Handles ADCheckForUpdateAsyncMin.CheckForUpdateCompleted
    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")
        Return
    Else
        If (e.Cancelled) Then
            MessageBox.Show("The application update has been cancelled.", "Application Update Cancelled")
            Return
        End If
    End If

    ADCheckForUpdateAsyncMin = ApplicationDeployment.CurrentDeployment
    If (e.MinimumRequiredVersion > ADCheckForUpdateAsyncMin.CurrentVersion) Then
        ' Launch an install of the minimum required version. 
        ADCheckForUpdateAsyncMin.UpdateAsync()
    End If
End Sub


Private Sub ADCheckForUpdateAsyncMin_UpdateCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs) Handles ADCheckForUpdateAsyncMin.UpdateCompleted
    ' Alert user that update is complete.
    If Not (e.Error Is Nothing) Then
        MessageBox.Show("Could not install application update. We will try and upgrade the application later.", "Application Update Error")
        Return
    Else
        If (e.Cancelled) Then
            MessageBox.Show("The application update has been cancelled.", "Application Update Cancelled")
            Return
        End If
    End If

    MessageBox.Show("The update was successful. Your application will now be restarted.", "Restart Application")
    Application.Restart()
End Sub

Remarques

Les applications peuvent manquer les mises à jour requises lorsqu’un utilisateur effectue une attribution spéciale ou s’il est absent de l’ordinateur pendant des semaines ou des mois. Utiliser

MinimumRequiredVersion pour déterminer si l’utilisateur n’a pas mis à niveau l’application dans un certain temps et a manqué une ou plusieurs mises à jour requises.

S’applique à