ClickOnce Automatic Updates Require Application Restart Despite Zero-Downtime Requirement
0 reputation · 29 Aug 2024, 15:23 UTC
0 reputation · 29 Aug 2024, 15:23 UTC
A VB.NET WinForms application targets .NET 8 and uses ClickOnce for deployment. The operations team requires true zero-downtime updates — meaning the running process must not restart when a new version is deployed.
The ApplicationDeployment.UpdateAsync method downloads the new deployment manifest and assemblies, but the documented behavior explicitly calls Application.Restart() to apply the update. ClickOnce does not leverage .NET's side-by-side assembly loading via AssemblyLoadContext for in-process hot-swapping.
It is unclear whether any supported configuration, event hook, or manifest setting can suppress the mandatory restart while still allowing the updated assemblies to be loaded into the existing process. The ApplicationDeployment class exposes CheckForUpdateCompleted and UpdateCompleted events, but documentation indicates the restart occurs before these events fire.
UpdateAsync completes?AssemblyLoadContext without process termination?35275 reputation · 29 Aug 2024, 19:09 UTC
No. ClickOnce cannot apply an update to a running .NET 8 WinForms process without terminating and restarting it. True zero-downtime updates are not supported by the ClickOnce API.
ClickOnce downloads the new deployment manifest and application files to a versioned cache, then the runtime must load the updated assemblies. Because the current process already holds references and file locks to the original assemblies, and ClickOnce does not use AssemblyLoadContext for in-process hot swapping, the only supported path is to end the current process and start a new one. Application.Restart() performs that termination.
ApplicationDeployment.UpdateAsync downloads the update and then triggers Application.Restart().UpdateCompleted and CheckForUpdateCompleted events fire, so those events cannot cancel or defer it.AssemblyLoadContext supports unloading in custom scenarios, but ClickOnce-managed assemblies are not loaded into a swappable context for in-process replacement.Using a custom deployment manifest or non-standard ClickOnce host does not change the supported answer, though it may affect unsupported workarounds.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.