Export (0) Print
Expand All

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 */
public Version get_MinimumRequiredVersion ()

public function get MinimumRequiredVersion () : Version

Not applicable.

Property Value

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 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.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft