System.Reflection.Metadata
                              
                            
                                9.0.10
                            
                        
                            
                                
                                
                                    Prefix Reserved
                                
                            
                    See the version list below for details.
dotnet add package System.Reflection.Metadata --version 9.0.10
NuGet\Install-Package System.Reflection.Metadata -Version 9.0.10
<PackageReference Include="System.Reflection.Metadata" Version="9.0.10" />
<PackageVersion Include="System.Reflection.Metadata" Version="9.0.10" />
<PackageReference Include="System.Reflection.Metadata" />
paket add System.Reflection.Metadata --version 9.0.10
#r "nuget: System.Reflection.Metadata, 9.0.10"
#:package System.Reflection.Metadata@9.0.10
#addin nuget:?package=System.Reflection.Metadata&version=9.0.10
#tool nuget:?package=System.Reflection.Metadata&version=9.0.10
About
This package provides a low-level .NET (ECMA-335) metadata reader and writer. It's geared for performance and is the ideal choice for building higher-level libraries that intend to provide their own object model, such as compilers. The metadata format is defined by the ECMA-335 - Common Language Infrastructure (CLI) specification and its amendments.
The System.Reflection.Metadata library is included in the .NET Runtime shared framework. The package can be installed when you need to use it in other target frameworks.
How to Use
The following example shows how to read assembly information using PEReader and MetadataReader.
using System;
using System.IO;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
class Program
{
    static void Main()
    {
        // Open the Portable Executable (PE) file
        using var fs = new FileStream("Example.dll", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
        using var peReader = new PEReader(fs);
        // Display PE header information
        PEHeader header = peReader.PEHeaders.PEHeader;
        Console.WriteLine($"Image base:     0x{header.ImageBase:X}");
        Console.WriteLine($"File alignment: 0x{header.FileAlignment:X}");
        Console.WriteLine($"Subsystem:      {header.Subsystem}");
        // Display .NET metadata information
        if (!peReader.HasMetadata)
        {
            Console.WriteLine("Image does not contain .NET metadata");
            return;
        }
        MetadataReader mr = peReader.GetMetadataReader();
        AssemblyDefinition ad = mr.GetAssemblyDefinition();
        Console.WriteLine($"Assembly name:  {ad.GetAssemblyName().ToString()}");
        Console.WriteLine();
        Console.WriteLine("Assembly attributes:");
        foreach (CustomAttributeHandle attrHandle in ad.GetCustomAttributes())
        {
            CustomAttribute attr = mr.GetCustomAttribute(attrHandle);
            // Display the attribute type full name
            if (attr.Constructor.Kind == HandleKind.MethodDefinition)
            {
                MethodDefinition mdef = mr.GetMethodDefinition((MethodDefinitionHandle)attr.Constructor);
                TypeDefinition tdef = mr.GetTypeDefinition(mdef.GetDeclaringType());
                Console.WriteLine($"{mr.GetString(tdef.Namespace)}.{mr.GetString(tdef.Name)}");
            }
            else if (attr.Constructor.Kind == HandleKind.MemberReference)
            {
                MemberReference mref = mr.GetMemberReference((MemberReferenceHandle)attr.Constructor);
                if (mref.Parent.Kind == HandleKind.TypeReference)
                {
                    TypeReference tref = mr.GetTypeReference((TypeReferenceHandle)mref.Parent);
                    Console.WriteLine($"{mr.GetString(tref.Namespace)}.{mr.GetString(tref.Name)}");
                }
                else if (mref.Parent.Kind == HandleKind.TypeDefinition)
                {
                    TypeDefinition tdef = mr.GetTypeDefinition((TypeDefinitionHandle)mref.Parent);
                    Console.WriteLine($"{mr.GetString(tdef.Namespace)}.{mr.GetString(tdef.Name)}");
                }
            }
        }
    }
}
Main Types
The main types provided by this library are:
- System.Reflection.Metadata.MetadataReader
- System.Reflection.PortableExecutable.PEReader
- System.Reflection.Metadata.Ecma335.MetadataBuilder
- System.Reflection.PortableExecutable.PEBuilder
- System.Reflection.PortableExecutable.ManagedPEBuilder
Additional Documentation
- System.Reflection.Metadata.MetadataReader
- System.Reflection.PortableExecutable.PEReader
- System.Reflection.Metadata.Ecma335.MetadataBuilder
- System.Reflection.PortableExecutable.PEBuilder
- System.Reflection.PortableExecutable.ManagedPEBuilder
Feedback & Contributing
System.Reflection.Metadata is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. | 
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. | 
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. | 
| MonoAndroid | monoandroid was computed. | 
| MonoMac | monomac was computed. | 
| MonoTouch | monotouch was computed. | 
| Tizen | tizen40 was computed. tizen60 was computed. | 
| Xamarin.iOS | xamarinios was computed. | 
| Xamarin.Mac | xamarinmac was computed. | 
| Xamarin.TVOS | xamarintvos was computed. | 
| Xamarin.WatchOS | xamarinwatchos was computed. | 
- 
                                                    .NETFramework 4.6.2- System.Collections.Immutable (>= 9.0.10)
- System.Memory (>= 4.5.5)
 
- 
                                                    .NETStandard 2.0- System.Collections.Immutable (>= 9.0.10)
- System.Memory (>= 4.5.5)
 
- 
                                                    net8.0- System.Collections.Immutable (>= 9.0.10)
 
- 
                                                    net9.0- No dependencies.
 
GitHub repositories (263)
Showing the top 20 popular GitHub repositories that depend on System.Reflection.Metadata:
| Repository | Stars | 
|---|---|
| icsharpcode/ILSpy 
                                                            .NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
                                                         | |
| dotnet/roslyn 
                                                            The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
                                                         | |
| DapperLib/Dapper 
                                                            Dapper - a simple object mapper for .Net
                                                         | |
| winsw/winsw 
                                                            A wrapper executable that can run any executable as a Windows service, in a permissive license.
                                                         | |
| chocolatey/choco 
                                                            Chocolatey - the package manager for Windows
                                                         | |
| mRemoteNG/mRemoteNG 
                                                            mRemoteNG is the next generation of mRemote, open source, tabbed, multi-protocol, remote connections manager.
                                                         | |
| neuecc/UniRx 
                                                            Reactive Extensions for Unity
                                                         | |
| stride3d/stride 
                                                            Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
                                                         | |
| NancyFx/Nancy 
                                                            Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
                                                         | |
| StackExchange/StackExchange.Redis 
                                                            General purpose redis client
                                                         | |
| dotnet/msbuild 
                                                            The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
                                                         | |
| protobuf-net/protobuf-net 
                                                            Protocol Buffers library for idiomatic .NET 
                                                         | |
| UnigramDev/Unigram 
                                                            Telegram for Windows
                                                         | |
| microsoft/perfview 
                                                            PerfView is a CPU and memory performance-analysis tool
                                                         | |
| Fody/Fody 
                                                            Extensible tool for weaving .net assemblies
                                                         | |
| microsoft/ApplicationInspector 
                                                            A source code analyzer built for surfacing features of interest and other characteristics to answer the question 'What's in the code?' quickly using static analysis with a json based rules engine. Ideal for scanning components before use or detecting feature level changes.
                                                         | |
| cake-build/cake 
                                                            :cake: Cake (C# Make) is a cross platform build automation system.
                                                         | |
| ravendb/ravendb 
                                                            ACID Document Database
                                                         | |
| fluentassertions/fluentassertions 
                                                            A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, as well as .NET Core 2.1, .NET Core 3.0, .NET 6, .NET Standard 2.0 and 2.1. Supports the unit test frameworks MSTest2, NUnit3, XUnit2, MSpec, and NSpec3.
                                                         | |
| dotnet/interactive 
                                                            .NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
                                                         | 
| Version | Downloads | Last Updated | 
|---|---|---|
| 10.0.0-rc.2.25466.103 | 0 | 9/22/2025 | 
| 10.0.0-rc.1.25451.107 | 0 | 9/22/2025 | 
| 10.0.0-rc.1.25421.113 | 0 | 9/12/2025 | 
| 10.0.0-preview.7.25380.108 | 0 | 8/11/2025 | 
| 10.0.0-preview.7.25380.105 | 0 | 8/6/2025 | 
| 10.0.0-preview.6.25358.103 | 0 | 7/17/2025 | 
| 10.0.0-preview.6.25321.102 | 0 | 6/25/2025 | 
| 10.0.0-preview.5.25280.105 | 0 | 6/2/2025 | 
| 10.0.0-preview.5.25277.114 | 0 | 6/3/2025 | 
| 10.0.0-preview.5.25277.101 | 0 | 5/29/2025 | 
| 10.0.0-preview.5.25266.103 | 0 | 5/20/2025 | 
| 10.0.0-preview.4.25255.103 | 0 | 5/12/2025 | 
| 9.0.10 | 0 | 9/23/2025 | 
| 9.0.7 | 0 | 7/11/2025 | 
| 1.7.0-preview.19073.11 | 2 | 1/28/2019 | 
| 1.7.0-preview.18571.3 | 1 | 11/30/2018 | 
| 1.0.22 | 22,990 | 7/20/2015 | 
| 1.0.22-beta-23019 | 299 | 6/29/2015 | 
| 1.0.19-rc | 9,299 | 3/6/2015 | 
| 1.0.18-beta | 112,579 | 12/10/2014 | 
| 1.0.17-beta | 62,036 | 10/10/2014 |