Share via


Assembly.LoadFile 方法

定义

加载程序集文件的内容。

重载

LoadFile(String)

加载指定路径上的程序集文件的内容。

LoadFile(String, Evidence)
已过时.

在给定路径的情况下加载程序集,并使用提供的证据加载程序集。

LoadFile(String)

Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs

加载指定路径上的程序集文件的内容。

public:
 static System::Reflection::Assembly ^ LoadFile(System::String ^ path);
public static System.Reflection.Assembly LoadFile (string path);
static member LoadFile : string -> System.Reflection.Assembly
Public Shared Function LoadFile (path As String) As Assembly

参数

path
String

要加载的文件的完全限定路径。

返回

加载的程序集。

例外

path 参数不是绝对路径。

path 参数为 null

无法加载已找到的文件。

- 或 -

仅限.NET Framework:path指定基于 <loadFromRemoteSources> 禁用的位置。

path 参数为空字符串 ("") 或不存在。

path 对于当前加载的运行时,不是有效的程序集。

注解

LoadFile使用 方法加载和检查具有相同标识但位于不同路径的程序集。 LoadFile 不会将文件加载到 load-from 上下文中,也不会像 方法那样 LoadFrom 使用加载路径解析依赖项。 LoadFile 在此有限方案中很有用,因为 LoadFrom 不能用于加载具有相同标识但不同路径的程序集;它将仅加载第一个此类程序集。

仅.NET Framework:请参阅<loadFromRemoteSources>从远程位置加载程序集。

适用于

LoadFile(String, Evidence)

注意

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.

在给定路径的情况下加载程序集,并使用提供的证据加载程序集。

public:
 static System::Reflection::Assembly ^ LoadFile(System::String ^ path, System::Security::Policy::Evidence ^ securityEvidence);
public static System.Reflection.Assembly LoadFile (string path, System.Security.Policy.Evidence securityEvidence);
[System.Obsolete("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.")]
public static System.Reflection.Assembly LoadFile (string path, System.Security.Policy.Evidence securityEvidence);
static member LoadFile : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
[<System.Obsolete("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.")>]
static member LoadFile : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
Public Shared Function LoadFile (path As String, securityEvidence As Evidence) As Assembly

参数

path
String

程序集文件的完全限定路径。

securityEvidence
Evidence

用于加载程序集的证据。

返回

加载的程序集。

属性

例外

path 参数不是绝对路径。

path 参数为 null

path 参数为空字符串 ("") 或不存在。

无法加载已找到的文件。

- 或 -

path 指定基于 <loadFromRemoteSources> 禁用的位置。

path 对于当前加载的运行时,不是有效的程序集。

securityEvidence 不是 null。 默认情况下,在 .NET Framework 4 中不启用旧 CAS 策略;如果未启用,securityEvidence则必须为 null

注解

LoadFile使用 方法加载和检查具有相同标识但位于不同路径的程序集。 LoadFile 不会将文件加载到上下文中 LoadFrom ,也不会像 方法那样 LoadFrom 使用加载路径解析依赖项。 LoadFile 在此有限方案中很有用,因为 LoadFrom 不能用于加载具有相同标识但不同路径的程序集;它将仅加载第一个此类程序集。

有关从远程位置加载程序集的信息,请参阅 <loadFromRemoteSources>

适用于