Assembly.LoadFile Method (String, Evidence)
Loads an assembly given its path, loading the assembly into the domain of the caller using the supplied evidence.
[Visual Basic] Overloads Public Shared Function LoadFile( _ ByVal path As String, _ ByVal securityEvidence As Evidence _ ) As Assembly [C#] public static Assembly LoadFile( string path, Evidence securityEvidence ); [C++] public: static Assembly* LoadFile( String* path, Evidence* securityEvidence ); [JScript] public static function LoadFile( path : String, securityEvidence : Evidence ) : Assembly;
- The path of the assembly file.
- Evidence for loading the assembly.
The loaded assembly.
|ArgumentNullException||The path parameter is a null reference (Nothing in Visual Basic).|
|SecurityException||The caller does not have the required permission.|
|FileNotFoundException||The path parameter is the empty string ("") or does not exist.|
Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. Do not use LoadFile to load assemblies that you want to execute. 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.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- ReflectionPermission when invoked late-bound through mechanisms such as Type.InvokeMember. Associated enumeration: ReflectionPermissionFlag.MemberAccess.
- FileIOPermission 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.
- SecurityPermission to load an assembly with evidence. Associated enumeration: SecurityPermissionFlag.ControlEvidence.