Assembly.Load Method (String, Evidence)
Loads an assembly given its display name, loading the assembly into the domain of the caller using the supplied evidence.
Assembly: mscorlib (in mscorlib.dll)
public static function Load( assemblyString : String, assemblySecurity : Evidence ) : Assembly
- Type: System.String
The display name of the assembly.
- Type: System.Security.Policy.Evidence
Evidence for loading the assembly.
Return ValueType: System.Reflection.Assembly
The loaded assembly.
assemblyString is a null reference (Nothing in Visual Basic).
assemblyString is not found.
assemblyString is not a valid assembly.
Version 2.0 or later of the common language runtime is currently loaded and assemblyString was compiled with a later version.
A file that was found could not be loaded.
An assembly or module was loaded twice with two different evidences.
FileLoadException is thrown if assemblyString specifies the full assembly name, and the first assembly that matches the simple name has a different version, culture, or public key token. The loader does not continue probing for other assemblies that match the simple name.
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 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 common object file format (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.
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.
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.
If you call this 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.
In the .NET Framework version 2.0, processor architecture is added to assembly identity, and can be specified as part of assembly name strings. For example, "ProcessorArchitecture=msil". However, the recommended way to specify an assembly name is to create an AssemblyName object and pass it to an appropriate overload of the Load method. See AssemblyName.ProcessorArchitecture.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, 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.