ApplicationDeployment.CurrentVersion 属性

定义

获取当前正在运行的应用程序实例的部署版本。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

属性值

当前的部署版本。The current deployment version.

示例

下面的代码示例定义了一个方法, 该ClickOnceClickOnce方法确定是否已更新了应用程序。The following code example defines a method that determines whether ClickOnceClickOnce 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

注解

CurrentVersionUpdatedVersion如果已安装新的更新, 但尚未调用Restart, 则与不同。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.

安全性

PermissionSet
对本地计算机具有完全访问权限。For full access to the local computer. 关联枚举:PermissionStateAssociated enumeration: PermissionState.

适用于

另请参阅