Assembly.ReflectionOnlyLoad Assembly.ReflectionOnlyLoad Assembly.ReflectionOnlyLoad Assembly.ReflectionOnlyLoad Method

Definition

Loads an assembly into the reflection-only context, where it can be examined but not executed.

Overloads

ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[])

Loads the assembly from a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the reflection-only context of the caller's application domain.

ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String)

Loads an assembly into the reflection-only context, given its display name.

ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[])

Loads the assembly from a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the reflection-only context of the caller's application domain.

public:
 static System::Reflection::Assembly ^ ReflectionOnlyLoad(cli::array <System::Byte> ^ rawAssembly);
public static System.Reflection.Assembly ReflectionOnlyLoad (byte[] rawAssembly);
static member ReflectionOnlyLoad : byte[] -> System.Reflection.Assembly
Public Shared Function ReflectionOnlyLoad (rawAssembly As Byte()) As Assembly

Parameters

rawAssembly
Byte[]

A byte array that is a COFF-based image containing an emitted assembly.

Returns

The loaded assembly.

Exceptions

rawAssembly is not a valid assembly.

-or-

Version 2.0 or later of the common language runtime is currently loaded and rawAssembly was compiled with a later version.

Remarks

You cannot execute code from an assembly loaded into the reflection-only context. To execute code, the assembly must be loaded into the execution context as well, using the Load method.

The reflection-only context is no different from other contexts. Assemblies that are loaded into the context can be unloaded only by unloading the application domain.

ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String)

Loads an assembly into the reflection-only context, given its display name.

public:
 static System::Reflection::Assembly ^ ReflectionOnlyLoad(System::String ^ assemblyString);
public static System.Reflection.Assembly ReflectionOnlyLoad (string assemblyString);
static member ReflectionOnlyLoad : string -> System.Reflection.Assembly
Public Shared Function ReflectionOnlyLoad (assemblyString As String) As Assembly

Parameters

assemblyString
String String String String

The display name of the assembly, as returned by the FullName property.

Returns

The loaded assembly.

Exceptions

assemblyString is found, but cannot be loaded.

assemblyString is not a valid assembly.

-or-

Version 2.0 or later of the common language runtime is currently loaded and assemblyString was compiled with a later version.

Remarks

Dependencies are not automatically loaded into the reflection-only context.

You cannot execute code from an assembly loaded into the reflection-only context. To execute code, the assembly must be loaded into the execution context as well, using the Load method.

Whether certain permissions are granted or not granted to an assembly is based on evidence. The rules for assembly and security evidence merging are as follows:

Note

Reflecting on executable files compiled in C++ might throw a FileLoadException. This is most likely caused by the C++ compiler stripping the relocation addresses or the .reloc section from your executable file. To preserve the .reloc address, specify /fixed:no when you are linking.

The reflection-only context is no different from other contexts. Assemblies that are loaded into the context can be unloaded only by unloading the application domain.

Applies to