Skip to content

MetadataLoadContext to support dynamic assemblies #27803

@steveharter

Description

@steveharter

As part of the review for feature #15033 and PR dotnet/corefx#33201, there was concern about the lack of support for assemblies not backed by a physical file.

From the comments @jkotas:

There is no way to load runtime loaded assembly into MetadataLoadContext that it not backed by a physical file. The runtime has AssemblyExtensions.TryGetRawMetadata API to handle this case, but there is no way to give the blob returned by TryGetRawMetadata to MetadataLoadContext. The assemblies not backed by physical file are rare today, but they are very likely going to become more common as part of the single-file project.
I am wondering whether there should be a LoadFrom method that takes MetadataReaderProvider to address both these problems and/or whether we should expose a resolver that can resolve the runtime loaded assemblies for you.

Implementation\design TBD. One approach is to use runtime reflection over the dynamic assembly, and convert those from System.RuntimeType to the MetadataLoadContext types (System.RoType).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.ReflectionenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions