Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

CheckForUpdateCompletedEventArgs.MinimumRequiredVersion Property

Gets the minimum version that the user must have installed on the computer.

Namespace:  System.Deployment.Application
Assembly:  System.Deployment (in System.Deployment.dll)
public Version MinimumRequiredVersion { get; }

Property Value

Type: System.Version
A Version object expressing the earliest version that all users must install.

Applications can miss required updates when a user takes on a special assignment or is away from the computer for weeks or months. Use

MinimumRequiredVersion to determine if the user has not upgraded the application in a while, and has missed one or more required updates.

The following code example calls CheckForUpdateAsync, and forces an application update if MinimumRequiredVersion is greater than 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();
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.