microsoft / microsoft/winget-cli

CatalogPackage.DefaultInstallVersion throws an exception on Windows 10 since v1.11.400

Open
#5,569 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-COM-API Issue-Bug
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
  1. Create a composite catalog that contains any available sources on the device
  2. Connect to the catalog and obtain [all/some] packages.
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.