microsoft / microsoft/winget-cli
CatalogPackage.DefaultInstallVersion throws an exception on Windows 10 since v1.11.400
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.4k
- Forks
- 1.8k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
Brief description of your issue
After updating Winget to v1.11.400 my c# test application breaks on Windows 10 machines (on Win 11 it works fine). It tries to collect all Winget supported applications on the device. For this it creates a composite catalog and checks the package's DefaultInstallVersion property.:
CatalogPackage package = searchResult.Matches[i].CatalogPackage;
if (searchResult.Matches[i].CatalogPackage.DefaultInstallVersion != null)
{
wingetApps.Add(new(package.InstalledVersion.Id, package.Id, package.InstalledVersion.DisplayName, package.DefaultInstallVersion.PackageCatalog.Info.Name, productCode, package.InstalledVersion.Version));
}
Previously this code was working fine on win10, but after the update, if the package has Winget support, reading the DefaultInstallVersion throws a System.Runtime.InteropServices.COMException without any additional info. The stacktrace:
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
at ABI.Microsoft.Management.Deployment.ICatalogPackageMethods.get_DefaultInstallVersion(IObjectReference _obj)
at Microsoft.Management.Deployment.CatalogPackage.get_DefaultInstallVersion()
at SoftwareDiscovery.Helpers.Inventory.WingetHelper.GetWingetHandledApps() in
First I tried it with the old COM interop nuget package (v1.10.340), then with the new one (v1.11.400) but the result was the same.
Steps to reproduce
- Create a composite catalog that contains any available sources on the device
- Connect to the catalog and obtain [all/some] packages.
- Iterate over the obtained packages and try to read
DefaultInstallVersion. - If the package has Winget support it throws an exception
Expected behavior
Reading the DefaultInstallVersion should return the package info, just like on win 11.
Actual behavior
CatalogPackage throws an exception when trying to read the DefaultInstallVersion prop.
Environment
Windows Package Manager v1.11.400
Copyright (c) Microsoft Corporation. All rights reserved.
Windows: Windows.Desktop v10.0.19045.5965
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.26.400.0
Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User) %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User) %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root C:\Program Files\WinGet\Packages
Portable Package Root (x86) C:\Program Files (x86)\WinGet\Packages
Installer Downloads %USERPROFILE%\Downloads
Configuration Modules %LOCALAPPDATA%\Microsoft\WinGet\Configuration\Modules
Links
---------------------------------------------------------------------------
Privacy Statement https://aka.ms/winget-privacy
License Agreement https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
Admin Setting State
--------------------------------------------------
LocalManifestFiles Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride Disabled
LocalArchiveMalwareScanOverride Disabled
ProxyCommandLineOptions Disabled
DefaultProxy Disabled
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the composite-catalog scenario on Windows 10 v10.0.19045.5965 with Windows Package Manager v1.11.400, then compare reading CatalogPackage.DefaultInstallVersion on Windows 11. Done means the property no longer throws a System.Runtime.InteropServices.COMException for packages with Winget support and returns the package information described in the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- api, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100