AssemblyLoadContext.LoadFromAssemblyName(AssemblyName) Method

Definition

Resolves and loads an assembly given its AssemblyName.

public:
 System::Reflection::Assembly ^ LoadFromAssemblyName(System::Reflection::AssemblyName ^ assemblyName);
public System.Reflection.Assembly LoadFromAssemblyName (System.Reflection.AssemblyName assemblyName);
member this.LoadFromAssemblyName : System.Reflection.AssemblyName -> System.Reflection.Assembly
Public Function LoadFromAssemblyName (assemblyName As AssemblyName) As Assembly

Parameters

assemblyName
AssemblyName

The object that describes the assembly to load.

Returns

The loaded assembly, or throws.

Exceptions

assemblyName is null.

assemblyName is not found.

assemblyName is not a valid assembly.

An assembly or module was loaded which did not match the assemblyName.

Remarks

LoadFromAssemblyName loads an assembly by resolving the AssemblyName. This triggers a full resolution. The resolution fallback sequence follows this process:

  1. The method calls Load(AssemblyName).

    Important

    Load(AssemblyName) must not call this method to prevent recursive stack overflow.

  2. Unless the assembly is loaded or an exception is thrown, the method attempts to load the assembly in the default AssemblyLoadContext.

  3. Unless the assembly is loaded or an exception is thrown, the method fires the Resolving event.

  4. Unless the assembly is loaded or an exception is thrown, the method fires the AssemblyResolve event.

Note

FileLoadException is thrown if assemblyRef specifies the full assembly name, and the first assembly that matches the simple name has a incompatible version or culture. The loader does not continue probing for other assemblies that match the simple name.

Each AssemblyLoadContext can load only:

  • One version of an executable assembly.
  • One version of a satellite assembly for each culture.

Applies to

See also