I have a NetCore3.1 WPF Application (Windows 10, VS2019). I can pack it as MSIX app (using official documentation).
In the .appxmanifest
file I added:
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="packageQuery" />
</Capabilities>
I can install and use my application without problems. The problem is that I try to use the Windows.Management API in my application like so:
var pkgManager = new Windows.Management.Deployment.PackageManager();
IEnumerable<Windows.ApplicationModel.Package> packages = pkgManager.FindPackagesForUser("");
I dont get any exceptions when using this but the packages
variable value is System.__ComObject
.
I dont understand what exactly is that and why am I not getting the desired result - a list of all installed msix packages for the user.
I managed to (sort of) solve my problem.
I still have no idea why is my packages variable System.__ObjectCom and what exactly is System.__ObjectCom but it seems that if one treats this object as the supposed-to-be object (in my case IEnumerable<Windows.ApplicationModel.Package>) its ok.
So basically, the following produced something (much to my surprise):
IEnumerable<Windows.ApplicationModel.Package> packages = pkgManager.FindPackagesForUser("");
List<string> installedAppsDisplayNAme = new List<string>();
foreach (var package in packages)
{
installedAppsDisplayNAme.Add(package.DisplayName);
}