Edit

Assembly.LoadFile(String) Method

Definition

Loads the contents of an assembly file on the specified path.

public:
 static System::Reflection::Assembly ^ LoadFile(System::String ^ path);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
public static System.Reflection.Assembly LoadFile(string path);
public static System.Reflection.Assembly LoadFile(string path);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")>]
static member LoadFile : string -> System.Reflection.Assembly
static member LoadFile : string -> System.Reflection.Assembly
Public Shared Function LoadFile (path As String) As Assembly

Parameters

path
String

The fully qualified path of the file to load.

Returns

The loaded assembly.

Attributes

Exceptions

The path argument is not an absolute path.

The path parameter is null.

A file that was found could not be loaded.

-or-

.NET Framework only: path specifies a location that is disabled based on <loadFromRemoteSources>.

The path parameter is an empty string ("") or does not exist.

path is not a valid assembly for the currently loaded runtime.

Remarks

This API is present in .NET Core for compatibility, but it's recommended to use AssemblyLoadContext overloads instead.

The assembly is loaded into a new AssemblyLoadContext created for this purpose. For more information on assembly loading, see Managed assembly loading algorithm.

Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. LoadFile does not load files into the load-from context, and does not resolve dependencies using the load path, as the LoadFrom method does. LoadFile is useful in this limited scenario because LoadFrom cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.

.NET Framework only: See <loadFromRemoteSources> for loading assemblies from remote locations.

Applies to