Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Assembly Class
Assembly Methods
Load Method
 Load Method (Byte[])
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Assembly..::.Load Method (array<Byte>[]()[])

Updated: November 2007

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the domain of the caller.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Visual Basic (Declaration)
Public Shared Function Load ( _
    rawAssembly As Byte() _
) As Assembly
Visual Basic (Usage)
Dim rawAssembly As Byte()
Dim returnValue As [Assembly]

returnValue = Assembly.Load(rawAssembly)
C#
public static Assembly Load(
    byte[] rawAssembly
)
Visual C++
public:
static Assembly^ Load(
    array<unsigned char>^ rawAssembly
)
J#
public static Assembly Load(
    byte[] rawAssembly
)
JScript
public static function Load(
    rawAssembly : byte[]
) : Assembly

Parameters

rawAssembly
Type: array<System..::.Byte>[]()[]

An array of type byte that is a COFF-based image containing an emitted assembly.

Return Value

Type: System.Reflection..::.Assembly

The loaded assembly.

ExceptionCondition
ArgumentNullException

rawAssembly is nullNothingnullptra null reference (Nothing in Visual Basic).

BadImageFormatException

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.

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:

  • When you use a Load method with no Evidence parameter, the assembly is loaded with the evidence that the loader supplies.

  • When you use a Load method with an Evidence parameter, pieces of evidence are merged. Pieces of evidence supplied as an argument to the Load method supersede pieces of evidence supplied by the loader.

  • When you use a Load method overload with a Byte[] parameter to load a COFF image, evidence is inherited from the calling assembly. This applies to the .NET Framework version 1.1 Service Pack 1 (SP1) and subsequent releases.

    Note:

    In the .NET Framework version 1.0 and in version 1.1 without SP1, when you use a Load method overload with a Byte[] parameter to load a COFF image, evidence is combined. Zone, Url and Site are inherited from the calling assembly, and Hash and StrongName are taken from the COFF assembly.

  • When you use a Load method with a Byte[] parameter and Evidence to load a COFF image, only the supplied evidence is used. Evidence of the calling assembly and evidence of the COFF image is ignored.

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

Note that this method overload always creates a new Assembly object with its own mapping.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker