Skip to content

AssemblyLoadContext add ContextInfo #28398

Closed

Description

@sdmaclea

There is a desire to provide more context information during loading to enable more advanced scenarios.

An initial proposal would be to add

public struct ContextInfo
{
    public System.Reflection.Assembly Requestor { get; }
}

And then add additional extended virtual methods, events and delegates

[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public delegate 
void AssemblyLoadExtendedEventHandler(object sender, 
                                      System.Reflection.AssemblyName assemblyName,
                                      ContextInfo info);

[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public delegate 
void UnmanagedLoadExtendedEventHandler(object sender, 
                                       string unmanagedDllName,
                                       ContextInfo info);}

public class AssemblyLoadContext
{
    protected virtual System.Reflection.Assembly Load (System.Reflection.AssemblyName assemblyName, ContextInfo info)
    {
       return Load(assemblyName);
    }

    protected virtual IntPtr LoadUnmanagedDll (string unmanagedDllName, assemblyName, ContextInfo info)
    {
        return LoadUnmanagedDll(unmanagedDllName);
    }

    public event AssemblyLoadExtendedEventHandler ResolvingExtended;
    public event UnmanagedLoadExtendedEventHandler ResolvingUnmanagedDllExtended;
}

Activity

  1. self-assigned this
    on Jan 11, 2019
  2. sdmaclea commented on Jan 11, 2019

    @sdmaclea
    ContributorAuthor

    This is based on a brief discussion I had with @jeffschwMSFT

    /cc @vitek-karas @swaroop-sridhar @jkotas @sbomer

  3. jkotas commented on Jan 11, 2019

    @jkotas
    Member

    What kind of more advanced scenarios is this for?

    One of the key invariants of AssemblyLoadContext is that it should be load order independent. This new argument just adds a new way how people can violate this invariant.

  4. sdmaclea commented on Jan 11, 2019

    @sdmaclea
    ContributorAuthor

    What kind of more advanced scenarios is this for?

    My understanding was it to help in finding neighboring assemblies and satellites. I think we will address the satellite issue with the other active threads. I am not sure about neighboring assemblies.

    @jkotas I don't really have a strong justification for this. I intended to start the discussion it was on the wish list. I think @jeffschwMSFT would be best to document his motivation.

  5. transferred this issue fromdotnet/corefxon Feb 1, 2020
  6. added this to the 3.0 milestone on Feb 1, 2020
  7. ghost locked as resolved and limited conversation to collaborators on Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-needs-workarea-System.Runtime

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions