次の方法で共有


ApplicationDeployment.CurrentVersion Property

Definition

Gets the version of the deployment for the current running instance of the application.

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

Property Value

The current deployment version.

Examples

The following code example defines a method that determines whether ClickOnce has updated the application.

public:
    bool CheckForUpdateDue()
    {
        bool isUpdateDue = false;

        if (ApplicationDeployment::IsNetworkDeployed)
        {
            ApplicationDeployment^ dueAppDeployment =
                ApplicationDeployment::CurrentDeployment;
            TimeSpan^ updateInterval =
                DateTime::Now - dueAppDeployment->TimeOfLastUpdateCheck;
            if (updateInterval->Days >= 3)
            {
                isUpdateDue = true;
            }
        }

        return (isUpdateDue);
    }
private Boolean CheckForUpdateDue()
{
    Boolean isUpdateDue = false;

    if (ApplicationDeployment.IsNetworkDeployed)
    {
        ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
        TimeSpan updateInterval = DateTime.Now - ad.TimeOfLastUpdateCheck;
        if (updateInterval.Days > 3)
        {
            isUpdateDue = true;
        }
    }

    return (isUpdateDue);
}
Private Function CheckForUpdateDue() As Boolean
    Dim isUpdateDue As Boolean = False

    If (ApplicationDeployment.IsNetworkDeployed) Then
        Dim AD As ApplicationDeployment = ApplicationDeployment.CurrentDeployment
        Dim updateInterval As TimeSpan = DateTime.Now - AD.TimeOfLastUpdateCheck
        If (updateInterval.Days > 3) Then
            isUpdateDue = True
        End If
    End If

    CheckForUpdateDue = isUpdateDue
End Function

Remarks

CurrentVersion will differ from UpdatedVersion if a new update has been installed but you have not yet called Restart. If the deployment manifest is configured to perform automatic updates, you can compare these two values to determine if you should restart the application.

Applies to

See also