System.Reflection.MetadataLoadContext 9.0.0

About

Provides read-only reflection on assemblies in an isolated context with support for assemblies that target different processor architectures and runtimes. Using MetadataLoadContext enables you to inspect assemblies without loading them into the main execution context. Assemblies in MetadataLoadContext are treated only as metadata, that is, you can read information about their members, but cannot execute any code contained in them.

How to Use

The following example shows how to print the list of types defined in an assembly.

using System;
using System.Reflection;

class Program
{
    static void Main()
    {
        string inspectedAssembly = "Example.dll";
        var resolver = new PathAssemblyResolver(new string[] {inspectedAssembly, typeof(object).Assembly.Location});
        using var mlc = new MetadataLoadContext(resolver, typeof(object).Assembly.GetName().ToString());

        // Load assembly into MetadataLoadContext
        Assembly assembly = mlc.LoadFromAssemblyPath(inspectedAssembly);
        AssemblyName name = assembly.GetName();

        // Print types defined in assembly
        Console.WriteLine($"{name.Name} has following types: ");

        foreach (Type t in assembly.GetTypes())
        {
            Console.WriteLine(t.FullName);
        }
    }
}

Main Types

The main types provided by this library are:

  • System.Reflection.MetadataLoadContext
  • System.Reflection.MetadataAssemblyResolver

Additional Documentation

Feedback & Contributing

System.Reflection.MetadataLoadContext is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on System.Reflection.MetadataLoadContext.

Packages Downloads
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
6
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
8
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
9
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
11
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
14
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
17
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
21
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
23
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
30
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
31
Microsoft.Build
This package contains the Microsoft.Build assembly which is used to create, edit, and evaluate MSBuild projects.
58

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

  • No dependencies.

.NET Standard 2.0

Version Downloads Last updated
9.0.0 5 11/16/2024
9.0.0-rc.2.24473.5 5 10/08/2024
9.0.0-rc.1.24431.7 7 09/15/2024
9.0.0-preview.7.24405.7 15 08/14/2024
9.0.0-preview.6.24327.7 14 07/10/2024
9.0.0-preview.5.24306.7 10 06/13/2024
9.0.0-preview.4.24266.19 9 05/24/2024
9.0.0-preview.3.24172.9 11 04/21/2024
9.0.0-preview.2.24128.5 8 03/14/2024
9.0.0-preview.1.24080.9 16 02/26/2024
8.0.1 5 10/09/2024
8.0.0 15 11/15/2023
8.0.0-rc.2.23479.6 13 10/22/2023
8.0.0-rc.1.23419.4 22 09/21/2023
8.0.0-preview.7.23375.6 12 09/02/2023
8.0.0-preview.6.23329.7 11 09/11/2023
8.0.0-preview.5.23280.8 24 07/03/2023
8.0.0-preview.4.23259.5 19 07/03/2023
8.0.0-preview.3.23174.8 23 04/15/2023
8.0.0-preview.2.23128.3 31 04/15/2023
8.0.0-preview.1.23110.8 60 03/25/2023
7.0.0 79 12/27/2022
7.0.0-rc.2.22472.3 80 10/15/2022
7.0.0-rc.1.22426.10 93 09/23/2022
7.0.0-preview.7.22375.6 39 09/23/2022
7.0.0-preview.6.22324.4 48 09/21/2022
7.0.0-preview.5.22301.12 33 09/26/2022
7.0.0-preview.4.22229.4 89 09/22/2022
7.0.0-preview.3.22175.4 89 09/22/2022
7.0.0-preview.2.22152.2 81 09/23/2022
7.0.0-preview.1.22076.8 38 09/22/2022
6.0.2-mauipre.1.22102.15 66 09/23/2022
6.0.2-mauipre.1.22054.8 71 09/22/2022
6.0.1 4 11/13/2024
6.0.0 80 09/22/2022
6.0.0-rc.2.21480.5 32 10/15/2022
6.0.0-rc.1.21451.13 28 09/23/2022
6.0.0-preview.7.21377.19 34 09/22/2022
6.0.0-preview.6.21352.12 107 09/22/2022
6.0.0-preview.5.21301.5 35 09/23/2022
6.0.0-preview.4.21253.7 75 09/23/2022
6.0.0-preview.3.21201.4 33 09/23/2022
6.0.0-preview.2.21154.6 49 09/24/2022
6.0.0-preview.1.21102.12 62 09/21/2022
5.0.1 80 09/22/2022
5.0.0 71 09/23/2022
5.0.0-rc.2.20475.5 51 09/23/2022
5.0.0-rc.1.20451.14 65 09/22/2022
5.0.0-preview.8.20407.11 26 09/22/2022
5.0.0-preview.7.20364.11 45 09/22/2022
5.0.0-preview.6.20305.6 55 09/21/2022
5.0.0-preview.5.20278.1 81 09/25/2022
5.0.0-preview.4.20251.6 40 10/15/2022
5.0.0-preview.3.20214.6 55 09/23/2022
5.0.0-preview.2.20160.6 74 09/22/2022
5.0.0-preview.1.20120.5 94 09/22/2022
4.7.2 51 09/24/2022
4.7.1 83 09/22/2022
4.7.0 40 09/21/2022
4.7.0-preview3.19551.4 53 09/22/2022
4.7.0-preview2.19523.17 51 09/22/2022
4.7.0-preview1.19504.10 71 09/23/2022
4.6.0 71 09/23/2022
4.6.0-rc1.19456.4 49 09/23/2022
4.6.0-preview9.19421.4 62 09/22/2022
4.6.0-preview9.19416.11 89 09/27/2022
4.6.0-preview8.19405.3 102 10/15/2022
4.6.0-preview7.19362.9 45 09/22/2022
4.6.0-preview6.19303.8 37 09/22/2022
4.6.0-preview6.19264.9 70 09/22/2022
4.6.0-preview5.19224.8 77 09/23/2022
4.6.0-preview4.19212.13 25 09/21/2022
4.6.0-preview3.19128.7 87 09/23/2022
4.6.0-preview.19073.11 50 09/23/2022
4.6.0-preview.18571.3 86 09/25/2022