Forum Discussion

KCSAG's avatar
KCSAG
Copper Contributor
Jul 03, 2023

Update MSIX package with PackageManager fails in x86

Hello,
 

I am currently working on updating my application deployed with MSIX package from my code.

To do that, I am using the object PackageManager and the associated method AddPackageByAppInstallerFileAsync.

The problem comes now, I want to set the targeted platform on x86 or “Any CPU” “Prefer 32 bits". And, with this targeted platform, the update fails with the error message :

System.Runtime.InteropServices.SEHException: 'An external component has thrown an exception'

It looks very weird because x86 software should works on x64 computer.

Also, I tried on an x86 Windows VM and it worked perfectly.

I also tried to target x64, and it worked as well.

To summarize :

Target x64 + x64 machine ⇒ Worked

Target x32 + x32 machine ⇒ Worked

Target x32 + x64 machine ⇒ Not worked

I found that AddPackageByAppInstallerFileAsync method is linked with "System.Runtime.WindowsRuntime" DLL. At the beginning, the reference to this DLL was given by a Nuget package, but I also tried to reference it by adding a reference to the DLL instead, but the result was the same.

Here is my update code :

        public async void InstallUpdate()
        {
            try
            {
                PackageManager pm = new PackageManager();
                await pm.AddPackageByAppInstallerFileAsync(
                    new Uri(URI_APPINSTALLER),
                    AddPackageByAppInstallerOptions.ForceTargetAppShutdown,
                                                                           
                    pm.GetDefaultPackageVolume());
            }
            catch (Exception e)
            {
                MessageBox.Show(+ e.Message);
            }
        }

To finish with, some information on my system :

Windows 10 64 bits ; 22H2 - 19045.3086

Visual Studio 17.6.4

 

Thank you !

  • EugeneBall's avatar
    EugeneBall
    Copper Contributor

    KCSAG Hello, have you found a solution yet ? I have the same problem and there doesn't seem to be a lot of information on our problem on Internet.

Resources