即使已禁用,C#应用程序部署也会自动打开

时间:2019-02-19 16:20:44

标签: c# .net deployment

我正在开发将应用程序部署到服务器的应用程序。 我从项目选项中禁用了自动检查更新的功能,并实现了手动检查更新的选项。

我不确定为什么,但是在我的代码序列运行之后,如果我选择不更新,则下次我的应用程序打开时,它将自动检查更新,并且有一个可用的“更新可用”窗口将打开。 任何帮助将不胜感激。

这是我的更新代码支票:

 public static bool? CheckIfTheresDeploymentUpdate(string installationPath)
    {
        UpdateCheckInfo info = null;

        if (ApplicationDeployment.IsNetworkDeployed)
        {
            ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

            try
            {
                var appId = new ApplicationIdentity(deployment.UpdatedApplicationFullName);
                var unrestrictedPerms = new PermissionSet(PermissionState.Unrestricted);
                var appTrust = new ApplicationTrust(appId)
                {
                    DefaultGrantSet = new PolicyStatement(unrestrictedPerms),
                    IsApplicationTrustedToRun = true,
                    Persist = true
                };
                ApplicationSecurityManager.UserApplicationTrusts.Add(appTrust);

                // Check for update
                info = deployment.CheckForDetailedUpdate();
            }
            catch (CompatibleFrameworkMissingException)
            {
                MessageBox.Show("Missing .NET Framework, Installing directly from server.");
                ManualUpdate();
                return null;
            }
            catch (Exception er)
            {
                Tools.ReportIssue("Update Issue", "in the update sequence", er);
                MessageBox.Show("Error in updater, updating directly from server.");
                ManualUpdate();
                return null;
            }
            return info.UpdateAvailable;
        }

        return null;

        void ManualUpdate()
        {
            if (File.Exists(installationPath))
                Process.Start(installationPath);
            else
                MessageBoxWithLinks.Show("Can't Update", "Couldn't do manual update, try use this link when network is available: {" + installationPath + "}", new string[] { installationPath });
        }
    }

0 个答案:

没有答案
相关问题