System.Reflection.Assembly.Load Method

Loads an assembly given its System.Reflection.AssemblyName.

Syntax

public static Assembly Load (AssemblyName assemblyRef)

Parameters

assemblyRef
The object that describes the assembly to be loaded.

Returns

The loaded assembly.

Remarks

System.IO.FileLoadException is thrown if assemblyRef 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.

Note:

Do not use an System.Reflection.AssemblyName with only the AssemblyName.CodeBase property set. The AssemblyName.CodeBase property does not supply any elements of the assembly identity (such as name or version), so loading does not occur according to load-by-identity rules, as you would expect from the Assembly.Load(AssemblyName) method. Instead, the assembly is loaded using load-from rules. For information about the disadvantages of using the load-from context, see the Assembly.LoadFrom(string) method overload or Best Practices for Assembly Loading.

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:

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.

Note:

If both the AssemblyName.Name property and the AssemblyName.CodeBase property are set, the first attempt to load the assembly uses the display name (including version, culture, and so on, as returned by the Assembly.FullName property). If the file is not found, AssemblyName.CodeBase is used to search for the assembly. If the assembly is found using AssemblyName.CodeBase, the display name is matched against the assembly. If the match fails, a System.IO.FileLoadException is thrown.

Requirements

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0