LoadFile Method (String)
Collapse the table of content
Expand the table of content

Assembly.LoadFile Method (String)

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

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

public static Assembly LoadFile (
	string path
public static Assembly LoadFile (
	String path
public static function LoadFile (
	path : String
) : Assembly
Not applicable.



The path of the file to load.

Return Value

The loaded assembly.

Exception typeCondition


The path parameter is a null reference (Nothing in Visual Basic).


A file that was found could not be loaded.


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


path is not a valid assembly.


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

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

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1

Community Additions

© 2015 Microsoft