Skip to content

[API Proposal]: Add constructor to AssemblyLoadContext that's accepting custom path #92074

Open
@SetTrend

Description

@SetTrend

Background and motivation

Current Situation

It’s such a common case to load a number of assemblies from a different location – in fact, this is the default case for using AssemblyLoadContext.

Yet, for implementing this simple and regular use case, it's required to manually derive from AssemblyLoadContext and to create your own implementation that’s doing nothing else than just providing AssemblyDependencyResolver with that path, making a mountain out of a molehill.

See Create a .NET Core application with plugins for reference.

Desired Situation

I propose to add a constructor to AssemblyLoadContext that’s accepting a file system directory path, so we can just use this constructor instead of being required to create a blatantly dispensable new class for this standard use case.

API Proposal

public AssemblyLoadContext(string filePath, string? name = null, bool isCollectible = false) {}

API Usage

new AssemblyLoadContext(@".\plugIns").LoadFromAssemblyPath(@".\plugIns\PlugIn1.dll")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions