question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Couldn't load the Windows Runtime assemblies in 7.1.2 (solved)

See original GitHub issue

Steps 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
farag2commented, Mar 12, 2021

LOL. I meant “familiar” with PS. ))

1reaction
SeeminglySciencecommented, Mar 12, 2021

It still doesnt output what PS 5.1 does. Or what am I doing wrong again?

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:

$all = [Windows.Management.Deployment.PackageManager]::new().FindPackages()
$all.AdditionalTypeData[[Collections.IEnumerable].TypeHandle]

/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 plain IInspectable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't load assembly because it is a newer runtime problem ...
It produces the error 'can't load assembly because it is built with a newer runtime than currently loaded'. By looking at the Modules...
Read more >
How to fix 'File or assembly "System.Runtime. ...
I searched for "WindowsRuntime" and "4.0.11.0" but I couldn't find anything. The error happens here so here is the code in this constructor:...
Read more >
DocConverter Release Notes 11.2.1
To use Microsoft Office converters, install the Microsoft Office applications before installing ActivePDF DocConverter. Hardware Requirements.
Read more >
Unable to initialize .net WPF Runtime/Maps SDK 200...
It now fails with the following error: 'Could not load ArcGIS Runtime (RuntimeCoreNet200_0.dll) or one of its dependencies. Ensure "Microsoft ...
Read more >
Understanding Windows x64 Assembly
This tutorial will focus on writing x64 assembly in Windows. Linux and OSX, which use the System V ABI calling conventions, will not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found