Assembly.Load Method (Byte[], Byte[], Evidence)

Note: This API is now obsolete. The non-obsolete alternative is Load.

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols and evidence for the assembly. The assembly is loaded into the application domain of the caller.

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

[ObsoleteAttribute("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlEvidence)]
public static Assembly Load(
	byte[] rawAssembly,
	byte[] rawSymbolStore,
	Evidence securityEvidence
)

Parameters

rawAssembly
Type: System.Byte[]

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

rawSymbolStore
Type: System.Byte[]

A byte array that contains the raw bytes representing the symbols for the assembly.

securityEvidence
Type: System.Security.Policy.Evidence

Evidence for loading the assembly.

Return Value

Type: System.Reflection.Assembly
The loaded assembly.

ExceptionCondition
ArgumentNullException

rawAssembly is null.

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.

FileLoadException

An assembly or module was loaded twice with two different evidences.

NotSupportedException

securityEvidence is not null. By default, legacy CAS policy is not enabled in the .NET Framework 4; when it is not enabled, securityEvidence must be null.

The assembly is loaded into the domain of the caller using the supplied evidence. The raw bytes representing the symbols for the assembly are also loaded.

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.

    NoteNote

    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 are ignored.

Reflecting on C++ executable files might throw a BadImageFormatException. 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 for your C++ executable file, specify /fixed:no when you are linking.

If you call the Load method more than once on the same assembly but with a different evidence specified, the common language runtime does not throw a FileLoadException because the equality and integrity of the different evidence specifications cannot be determined. The evidence that first succeeds is the evidence that is used.

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4

.NET Framework Client Profile

Supported in: 3.5 SP1
Obsolete (compiler warning) in 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft