【问题标题】:AutoUpdate application .net/wpf自动更新应用程序 .net/wpf
【发布时间】:2015-01-20 16:07:36
【问题描述】:

我寻求通过互联网更新我在“C#/.NET/WPF”中开发的程序的解决方案。 该项目包含具有不同文件类型和不同库 (dll) 的子目录。

到目前为止,我以 .zip 文件的形式分发了我的程序,该文件包含所有文件(总共 800kb)作为可移植解决方案。

我并不特别需要设置,但我寻求免费升级解决方案。

  • 我尝试了ClickOnce,但无法以“便携方式”分发应用程序,并且安装应用程序的地方不适合我。

  • 我看了WiX,但是有通过网络通知和更新的功能吗?

  • 其他解决方案?

【问题讨论】:

标签: c# .net wpf auto-update


【解决方案1】:

我在 msdn 上找到了类似的东西:

private void InstallUpdateSyncWithInfo()
{
    UpdateCheckInfo info = null;

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

        try
        {
            info = ad.CheckForDetailedUpdate();

        }
        catch (DeploymentDownloadException dde)
        {
            MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
            return;
        }
        catch (InvalidDeploymentException ide)
        {
            MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
            return;
        }
        catch (InvalidOperationException ioe)
        {
            MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
            return;
        }

        if (info.UpdateAvailable)
        {
            Boolean doUpdate = true;

            if (!info.IsUpdateRequired)
            {
                DialogResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel);
                if (!(DialogResult.OK == dr))
                {
                    doUpdate = false;
                }
            }
            else
            {
                // Display a message that the app MUST reboot. Display the minimum required version.
                MessageBox.Show("This application has detected a mandatory update from your current " + 
                    "version to version " + info.MinimumRequiredVersion.ToString() + 
                    ". The application will now install the update and restart.", 
                    "Update Available", MessageBoxButtons.OK, 
                    MessageBoxIcon.Information);
            }

            if (doUpdate)
            {
                try
                {
                    ad.Update();
                    MessageBox.Show("The application has been upgraded, and will now restart.");
                    Application.Restart();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
                    return;
                }
            }
        }
    }
}

http://msdn.microsoft.com/en-us/library/ms404263.aspx

要指定备用更新源,您可以使用 MageUI

1.打开 .NET Framework 命令提示符并键入: mageui.exe

2.在“文件”菜单上,选择“打开”以打开应用程序的部署清单。

3.选择部署选项选项卡。

4.在名为 Launch Location 的文本框中,输入指向将包含应用程序更新部署清单的目录的 URL。

5.保存部署清单。

【讨论】:

  • 我已经看到了,但是我不能将我的应用程序分发到“便携”版本,只想拥有 clickOnce 更新系统!总是有一个设置,我不想要。我想分发到 .zip。
  • 我想将我的应用程序分发到“便携式”+ AutoUpdate。
  • 我会自己更新自己的流程,不是很复杂。
猜你喜欢
  • 2010-09-08
  • 1970-01-01
  • 2014-06-08
  • 1970-01-01
  • 2020-12-01
  • 2018-11-05
  • 1970-01-01
  • 2012-03-31
  • 1970-01-01
相关资源
最近更新 更多