Load Method (AssemblyName)

Assembly.Load Method (AssemblyName)


Loads an assembly given its AssemblyName.

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

public static Assembly Load(
	AssemblyName assemblyRef


Type: System.Reflection.AssemblyName

The object that describes the assembly to be loaded.

Return Value

Type: System.Reflection.Assembly

The loaded assembly.

Exception Condition

assemblyRef is null.


assemblyRef is not found.


In the .NET for Windows Store apps or the , catch the base class exception, IOException, instead.

A file that was found could not be loaded.


assemblyRef is not a valid assembly. -or-

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

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.


Do not use an AssemblyName with only the CodeBase property set. The 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 Load 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 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:

  • 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 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.

  • 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 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 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, CodeBase is used to search for the assembly. If the assembly is found using CodeBase, the display name is matched against the assembly. If the match fails, a FileLoadException is thrown.

The following example instantiates an AssemblyName object and uses it to load the sysglobal.dll assembly. The example then displays the full name of the assembly's public types.

using System;
using System.Reflection;

public class Example
   public static void Main()
      String fullName = "sysglobl, Version=, Culture=neutral, " +
                        "PublicKeyToken=b03f5f7f11d50a3a, processor architecture=MSIL";
      var an = new AssemblyName(fullName);
      var assem = Assembly.Load(an);
      Console.WriteLine("Public types in assembly {0}:", assem.FullName);
      foreach (var t in assem.GetTypes())
         if (t.IsPublic)
            Console.WriteLine("   {0}", t.FullName);
// The example displays the following output:
//   Public types in assembly sysglobl, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:
//      System.Globalization.CultureAndRegionInfoBuilder
//      System.Globalization.CultureAndRegionModifiers


for access to read from a file or directory, and for access to the information in the path itself. Associated enumerations: FileIOPermissionAccess.Read, FileIOPermissionAccess.PathDiscovery


for reading a URI that does not begin with "file://".


to load an assembly with evidence. Associated enumeration: SecurityPermissionFlag.ControlEvidence

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft