Couldn't load the Windows Runtime assemblies in 7.1.2 (solved)
See original GitHub issueSteps to reproduce
I downloaded WinRT.Runtime.dll
1.1.3 from the CsWinRT page and Microsoft.Windows.SDK.NET.dll
from the Microsoft.Windows.SDK.NET.Ref page like it was described but cannot figure out why it still doesn’t work.
Add-Type -AssemblyName "D:\Desktop\WinRT.Runtime.dll"
Add-Type -AssemblyName "D:\Desktop\Microsoft.Windows.SDK.NET.dll"
[Windows.Management.Deployment.PackageManager,Windows.Web,ContentType=WindowsRuntime]::new().FindPackages() | Select-Object -ExpandProperty Id -Property DisplayName | Format-Table -Property Name
Expected behavior
Name
----
1527c705-839a-4832-9118-54d4Bd6a0c89
c5e2524a-ea46-4f67-841f-6a9465d9d515
E2A4F912-2574-4A75-9BB0-0D023378592B
F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE
Microsoft.AAD.BrokerPlugin
Microsoft.AccountsControl
Microsoft.AsyncTextService
Microsoft.BioEnrollment
Microsoft.CredDialogHost
Microsoft.ECApp
and so on...
Actual behavior
InvalidOperation: Unable to find type [Windows.Management.Deployment.PackageManager,Windows.Web, ContentType=WindowsRuntime].
Environment data
Name Value
PSVersion 7.1.2 PSEdition Core GitCommitId 7.1.2 OS Microsoft Windows 10.0.19042 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
Edited July, 5, 2022
Now it’s needed to used as it’s presented in PowerShell 5.1:
[Windows.Management.Deployment.PackageManager]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
LOL. I meant “familiar” with PS. ))
Well look at that…
You’re not doing anything wrong, they just seem to have changed up the design quite a bit. As a work around you can do:
/cc @daxian-dbw for awareness. It seems like they’ve made non-concrete types a lot more complicated to work with.
Edit: Or rather they used to have an
ABI.Systems.Collections.Generic.IEnumerable<>
concrete class for enumerable WinRT objects, but have now replaced that with a plainIInspectable
.