FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile' by daxian-dbw · Pull Request #12203 · PowerShell/PowerShell · GitHub

Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile' - #12203

Merged
Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
daxian-dbw:assembly
Mar 28, 2020
Merged

Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile'#12203
Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
daxian-dbw:assembly

Conversation

Dongbo Wang (daxian-dbw) commented Mar 25, 2020
edited
Loading

Copy link
Copy Markdown
Member

PR Summary

Fix #12052

Fix a regression in PS 7.0 introduced by #11088
PowerShell should discover assemblies loaded by Assembly.Load(byte[]) and Assembly.LoadFile as in prior versions.

Assemblies loaded by Assembly.Load(byte[]) and Assembly.LoadFile are placed in special AssemblyLoadContext instances of the type System.Runtime.Loader.IndividualAssemblyLoadContext. PowerShell should return assemblies from those load context instances.

Also include a minor change to ignore the .ionide folders, which are auto-generated by VS Code C# extension to hold symbol caches.

/cc Patrick Meinecke (@SeeminglyScience)

PR Checklist

Dongbo Wang (daxian-dbw) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Mar 25, 2020
Comment thread .gitignore
/// </summary>
private static IEnumerable<Assembly> GetPSVisibleAssemblies()
{
const string IndividualAssemblyLoadContext = "System.Runtime.Loader.IndividualAssemblyLoadContext";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

My concern is that IndividualAssemblyLoadContext is internal class and .Net is free to change the name.
Maybe more reliable to use an assembly context name ("Assembly.Load(byte[], ...)" and "Assembly.LoadFile({0})"). It is public contract and has one prefix Assembly.Load for both.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Any one can create a ALC instance with the name "Assembly.Load(byte[], ...)" or "Assembly.LoadFile(".
It's less reliable to depend on the name than the type. They can change the type name, but I think that possibility is very low, and we have test to catch the failure if the type name really changes.

Ilya (iSazonov) merged commit e741dc5 into PowerShell:master Mar 28, 2020
Ilya (iSazonov) changed the title Fix regression: pwsh should discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile' Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile' Mar 28, 2020
Dongbo Wang (daxian-dbw) deleted the assembly branch March 28, 2020 18:09

Copy link
Copy Markdown

🎉v7.1.0-preview.2 has been released which incorporates this pull request.:tada:

Handy links:

Copy link
Copy Markdown

🎉v7.0.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
…oadFile' (PowerShell#12203)

* Fix regression: pwsh should discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Powershell 7.x : Cannot use type from dll (built for netstandard2.0)

9 participants


Back | FazBrowse Home | New Git URL