AddPackageByAppInstallerFileAsync exception - file not found

75 Views Asked by At

I am trying to follow this documentation to update my app (winforms app bundled in an MSIX package) via code.
My package is published to a network share along with the .appinstaller file.
Manually installing/updating from the .appinstaller works fine, and letting Windows update at startup works fine too.
But when I try to initiate the update via code, I get an SEHException "External component has thrown an exception". The error code is -2147467259, which I believe is some kind of "file not found" error. Here's my code:

var pm = new PackageManager();
await pm.AddPackageByAppInstallerFileAsync(Package.Current.GetAppInstallerInfo().Uri,
          AddPackageByAppInstallerOptions.ForceTargetAppShutdown,             
          pm.GetDefaultPackageVolume());

I've ensured the value of Package.Current.GetAppInstallerInfo().Uri is correct - pasting the value into the Run dialog launches the installer.

Is there an issue with hosting the package on a share drive? Or am I doing something else wrong?

Edit: I've also tried publishing to a website and get the same error.

0

There are 0 best solutions below