MetadataReference.CreateFromImage Method

Definition

Overloads

CreateFromImage(IEnumerable<Byte>, MetadataReferenceProperties, DocumentationProvider, String)

Creates a reference to a single-module assembly or a standalone module stored in memory.

CreateFromImage(ImmutableArray<Byte>, MetadataReferenceProperties, DocumentationProvider, String)

Creates a reference to a single-module assembly or a standalone module stored in memory.

CreateFromImage(IEnumerable<Byte>, MetadataReferenceProperties, DocumentationProvider, String)

Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs

Creates a reference to a single-module assembly or a standalone module stored in memory.

public static Microsoft.CodeAnalysis.PortableExecutableReference CreateFromImage (System.Collections.Generic.IEnumerable<byte> peImage, Microsoft.CodeAnalysis.MetadataReferenceProperties properties = default, Microsoft.CodeAnalysis.DocumentationProvider documentation = default, string filePath = default);
public static Microsoft.CodeAnalysis.PortableExecutableReference CreateFromImage (System.Collections.Generic.IEnumerable<byte> peImage, Microsoft.CodeAnalysis.MetadataReferenceProperties properties = default, Microsoft.CodeAnalysis.DocumentationProvider? documentation = default, string? filePath = default);
static member CreateFromImage : seq<byte> * Microsoft.CodeAnalysis.MetadataReferenceProperties * Microsoft.CodeAnalysis.DocumentationProvider * string -> Microsoft.CodeAnalysis.PortableExecutableReference
Public Shared Function CreateFromImage (peImage As IEnumerable(Of Byte), Optional properties As MetadataReferenceProperties = Nothing, Optional documentation As DocumentationProvider = Nothing, Optional filePath As String = Nothing) As PortableExecutableReference

Parameters

peImage
IEnumerable<Byte>

Assembly image.

properties
MetadataReferenceProperties

Reference properties (extern aliases, type embedding, MetadataImageKind).

documentation
DocumentationProvider

Provides XML documentation for symbol found in the reference.

filePath
String

Optional path that describes the location of the metadata. The file doesn't need to exist on disk. The path is opaque to the compiler.

Returns

Exceptions

peImage is null.

Remarks

Performance considerations:

It is recommended to use CreateFromImage(IEnumerable<Byte>) or CreateFromImage(IEnumerable<Byte>) API when creating multiple references to the same metadata. Reusing Metadata object to create multiple references allows for sharing data across these references.

The method makes a copy of the data and pins it. To avoid making a copy use an overload that takes an ImmutableArray<T>. The pinned memory is released when the resulting reference becomes unreachable and GC collects it. To control the lifetime of the pinned memory deterministically use CreateFromStream(Stream, PEStreamOptions) to create an IDisposable metadata object and GetReference(DocumentationProvider, ImmutableArray<String>, Boolean, String, String) to get a reference to it.

Applies to

CreateFromImage(ImmutableArray<Byte>, MetadataReferenceProperties, DocumentationProvider, String)

Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs
Source:
MetadataReference.cs

Creates a reference to a single-module assembly or a standalone module stored in memory.

public static Microsoft.CodeAnalysis.PortableExecutableReference CreateFromImage (System.Collections.Immutable.ImmutableArray<byte> peImage, Microsoft.CodeAnalysis.MetadataReferenceProperties properties = default, Microsoft.CodeAnalysis.DocumentationProvider documentation = default, string filePath = default);
public static Microsoft.CodeAnalysis.PortableExecutableReference CreateFromImage (System.Collections.Immutable.ImmutableArray<byte> peImage, Microsoft.CodeAnalysis.MetadataReferenceProperties properties = default, Microsoft.CodeAnalysis.DocumentationProvider? documentation = default, string? filePath = default);
static member CreateFromImage : System.Collections.Immutable.ImmutableArray<byte> * Microsoft.CodeAnalysis.MetadataReferenceProperties * Microsoft.CodeAnalysis.DocumentationProvider * string -> Microsoft.CodeAnalysis.PortableExecutableReference
Public Shared Function CreateFromImage (peImage As ImmutableArray(Of Byte), Optional properties As MetadataReferenceProperties = Nothing, Optional documentation As DocumentationProvider = Nothing, Optional filePath As String = Nothing) As PortableExecutableReference

Parameters

peImage
ImmutableArray<Byte>

Assembly image.

properties
MetadataReferenceProperties

Reference properties (extern aliases, type embedding, MetadataImageKind).

documentation
DocumentationProvider

Provides XML documentation for symbol found in the reference.

filePath
String

Optional path that describes the location of the metadata. The file doesn't need to exist on disk. The path is opaque to the compiler.

Returns

Exceptions

peImage is null.

Remarks

Performance considerations:

It is recommended to use CreateFromImage(ImmutableArray<Byte>) or CreateFromImage(ImmutableArray<Byte>) API when creating multiple references to the same metadata. Reusing Metadata object to create multiple references allows for sharing data across these references.

The method pins peImage in managed heap. The pinned memory is released when the resulting reference becomes unreachable and GC collects it. To control the lifetime of the pinned memory deterministically use CreateFromImage(ImmutableArray<Byte>) to create an IDisposable metadata object and GetReference(DocumentationProvider, ImmutableArray<String>, Boolean, String, String) to get a reference to it.

The method creates a reference to a single-module assembly. To create a reference to a multi-module assembly or a stand-alone module use CreateFromImage(ImmutableArray<Byte>) and GetReference(DocumentationProvider, String, String).

Applies to