手动(静默)更新 ClickOnce 应用程序是否会成为部署更新的稳定方式?

发布于 2024-11-26 01:22:21 字数 457 浏览 0 评论 0 原文

我在公司网络内部署了一个应用程序,我希望更新过程需要用户更少的关注,类似于 Google Chrome 在后台安装更新的方式。我不需要给用户更新的选择。

我使用 System.Deployment 库来检测何时有新的 ClickOnce 更新可用并自动安装它们。我想知道更新完成后是否需要重新启动应用程序。目前,我在更新脚本末尾调用 Application.Restart()

但是,如果(为了使更新过程对用户更加透明)我执行了“静默”异步更新,然后显示一个图标,提示用户重新启动应用程序以应用更改,该怎么办?这会让应用程序变得不稳定吗?

此外,如果我在计时器上运行自定义 InstallUpdate() 进程(例如每 30 分钟一次),即使用户尚未重新启动,ClickOnce 是否仍能稳定地继续更新发布的每个新版本(注意:我希望更新仅在用户重新启动应用程序后应用)?

I've deployed an application inside a corporate network and I want the update process to require less attention from users, similar to how Google Chrome install updates - in the background. I don't need to give the user a choice to update.

I've used the System.Deployment library to detect when new ClickOnce updates are available and install them automatically. I'm wondering if its necessary to restart the app after the update is complete. Currently I invoke Application.Restart() at the end of my update script.

But what if (to make the update process more transparent for the user) I performed a 'silent' async update and then displayed an icon prompting the user to restart the app to apply the changes? Would this make the app unstable in any way?

Furthermore, if I ran my custom InstallUpdate() process on a timer, say every 30 minutes, would ClickOnce be stable to continue to update for every new version that was released even thought the user has not restarted (nb: I'm expecting the updates to only apply once the user restarts the app)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你与昨日 2024-12-03 01:22:21

我认为这取决于您的应用程序在启动时执行的操作、安装更新和重新启动应用程序时执行的操作以及更新包含的内容。您可以尝试运行它,然后附加一个调试器,看看它在做什么以及它有什么影响。

例如,我们的应用程序在启动时会将大量信息加载到内存中。如果更新包括对其中一种数据结构的更改,并且应用程序由于某种原因没有重新加载数据,则会导致问题。

I would think it depends on what your application does at startup, and what it's doing when the update is installed and the application is restarted, and what the update contains. You could try running it and then attaching a debugger to it and see what it's doing and what impact it has.

For example, our application loads a lot of information into memory when it starts up. If the update included a change to one of the data structures, and the app didn't reload the data for some reason, it would cause a problem.

少钕鈤記 2024-12-03 01:22:21

经过几年的这样做,我们发现可以通过这种方式静默安装更新。但是,有几个问题需要注意:

  1. 如果线程在 Update() 期间提前终止(例如:用户在更新正在进行时退出应用程序),则安装将损坏,并且下次用户加载应用程序时,ClickOnce 正常部署将启动并重新安装应用程序。

  2. 安装更新后,用户的桌面图标始终重新绘制(闪烁)。

  3. 调用 ApplicationDeployment.CurrentDeployment.CheckForUpdate() 超过 65536 次会导致 System.NullReferenceException 来源

    另一种方法是不实际检查更新,我发现这会锁定我的一个 dll 并阻止加载表单,因此请小心使用:

    If ApplicationDeployment.CurrentDeployment.Update then ' 更新应用程序
        console.writeline("已安装更新")
        ' 通知用户更新成功的代码,他们需要重新启动
    结束如果
    
  4. 如果您的 ClickOnce 项目是 32 位,并且您在 x64 上运行它平台,您的应用程序拥有的任何文件关联在执行手动 ClickOnce 更新后都将中断。请参阅此 MS 支持案例 了解更多详细信息。

After a few years of doing it like this, we have found that it is possible to silently install updates this way. However there are a few issues to be aware of:

  1. If the thread terminates prematurely during the Update() (eg: the user exits out of the app while the updating is in progress), the install will become corrupt and the next time the user loads the app, the ClickOnce normal deployment will fire off and re-install the app.

  2. The user's desktop icons always redraw (flicker) after an update is installed.

  3. Calling ApplicationDeployment.CurrentDeployment.CheckForUpdate() more than 65536 times causes a System.NullReferenceException Source.

    An alternative is not to actually check for an update, I have found that this locks one of my dlls and prevented a form from loading, so use with care:

    If ApplicationDeployment.CurrentDeployment.Update Then ' update app
        console.writeline("update installed")
        ' code to inform user update was sucessfull and they need to restart
    End If
    
  4. If your ClickOnce project is 32bit, and you run it on an x64 platform, any file associations your app has will break after performing a manual ClickOnce update. See this MS support case for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文