A custom deployment of ClickOnce application starts the reinstallation process every time the user logs off and logs back again

While working on customer case, I came across an interesting issue with an application deployed using ClickOnce.

Issue Description:

A custom deployment of ClickOnce application starts the reinstallation process every time the user logs off and logs back again.

Cause:

We worked on the machine and found the following registry key that belongs to the ClickOnce isolation store was getting deleted during each logoff.

HKEY_CURRENT_USER\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\SideBySide\2.0\PackageMetadata

When the user is logged in, a handle is created for the HKCU\Software\Classes hive, if a logoff could not unload this hive properly, it might get corrupted or hold incorrect data. This leads to get the corrupted data loaded back during logon.

In our case there was a problem with a single User Profile. These registry keys were getting removed or modified and was triggering the re-installation.

In a normal scenario, these registry keys do not get removed or modified, that provides the persistence to the application deployed using ClickOnce. In other words no re-installation occurs until there is a new update that is available and needs to be installed.

Possible Resolution

System processes and applications occasionally maintain connections to registry keys in the UserProfile, even after a user logs off. In such cases, the user session fails to end entirely. When you use roaming user profiles in a network environment, this can result in problems like deletion or modification of registry hives.

To resolve this problem, install Microsoft User Profile Hive Cleanup Service (UPHClean). UPHClean monitors the computer while you log off, and then UPHClean unloads UserProfiles. The User Profile Hive Cleanup service helps us to make sure that user sessions are completely ended when a user logs off. (https://msdn.microsoft.com/en-us/library/aa910532.aspx)

The User Profile Hive Cleanup service monitors for users who have logged off and for whom registry hives are still loaded. When this occurs, the service determines which applications have handles that are opened to the hives and releases them. It logs the application name and what registry keys were left open. After this occurs, the system finishes unloading the profile.

For more information and for installing User profile Hive cleanup service we recommend the following KB: https://support.microsoft.com/kb/837115

 

Content by: Ajith Thomas