Export (0) Print
Expand All

Assembly.LoadFile Method (String, Evidence)

Note: This API is now obsolete. The non-obsolete alternative is LoadFile.

Loads an assembly given its path, loading the assembly into the domain of the caller using the supplied evidence.

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

[ObsoleteAttribute("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of LoadFile which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlEvidence)]
public static Assembly LoadFile(
	string path,
	Evidence securityEvidence
)

Parameters

path
Type: System.String

The path of the assembly file.

securityEvidence
Type: System.Security.Policy.Evidence

Evidence for loading the assembly.

Return Value

Type: System.Reflection.Assembly
The loaded assembly.

ExceptionCondition
ArgumentNullException

The path parameter is null.

FileNotFoundException

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

FileLoadException

A file that was found could not be loaded.

BadImageFormatException

path is not a valid assembly.

-or-

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

NotSupportedException

securityEvidence is not null. By default, legacy CAS policy is not enabled in the .NET Framework 4; when it is not enabled, securityEvidence must be null.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4

.NET Framework Client Profile

Supported in: 3.5 SP1
Obsolete (compiler warning) in 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft