How to fix application crash when modifying MSIX user registry using Windows 10 V2004
Prior to Windows 10 version 2004, if your MSIX package contained an HKCU registry and your application tried to modify it, the operation would crash.
In this article, we will go through before and after Windows 10 V2004 scenarios to check user registry’s behavior when tried to be updated.
In the technical field, the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER hives of the registry are familiar concepts.
When a user logs into the Windows desktop, their personal user hive is loaded as HKEY_CURRENT_USER.
MSIX containerized apps make use of an Application hive, which is a new form of hive introduced by MSIX. When a modern app is launched, the Application hive is loaded into the container processes, which are then executed.
As we have seen in the MSIX Supported Features by OS Version table, MSIX includes support for user registry changes starting with version 2004 of Windows 10.
Let’s see what this really implies.
Generically, the MSIX package stores the containerized registry of the package in standard “.dat” format.
An MSIX package can have up to three .dat files:
Learn more about registry changes and all you need to know about the MSIX technology from our MSIX Fundamentals ebook.
The User.dat file (when present) will contain a copy of the HKCU portion.
The UserClasses.dat file (when present) will contain a copy of the HKCU/Software/Classes area.
Let’s create a simple app that updates a registry key with a new value (HKCU\Software\TestHKCUMSIX\Demo).
The application looks like this:
We will use this application to test how some applications might alter the HKCU (HKEY_CURRENT_USER) registry (modify, create, or delete) when performing certain settings.
To test how the HKCU registry behaves prior and after Windows 10 V2004, we will use an MSIX project where we add the previously mentioned registry key with value 0.
This added registry ensures that the User.dat file is created in the MSIX package.
Why does MSIX not allow any HKCU changes in Win 10 V2004?
Once the app and MSIX package are created, let’s install it on a Windows 10 machine with the 1909 OS version.
Upon launching it, when we query the registry, it shows our initial value of 0.
When we click on “Update Registry” (which should update the registry with value 1), we notice we receive the following error:
You might think that during the development process, you can catch this error and choose not to display it to the user, and you would be right.
But in this case, we chose to display the error to see how MSIX does not allow any HKCU changes in this version.
How to Add, Modify and Delete your user current registry in MSIX Windows 10 V2004
We updated the image and tested the package on an OS version after 2004. After the installation, the app detects our default registry value to be 0.
However, if we now click “Update Registry”, MSIX now allows the application to perform changes on the HKCU registry, and if we query the registry again, the value is now modified to 1.
Are you encountering issues when updating your user registry in MSIX? If you are still on an OS version prior to 2004, we strongly encourage you to update to a newer version.
Not only will this eliminate the above mentioned issue, but it will bring many other improvements and additions to your MSIX.
Subscribe to Our Newsletter
Sign up for free and be the first to receive the latest news, videos, exclusive How-Tos, and guides from Advanced Installer.