Assembly.LoadFile 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
加载程序集文件的内容。
重载
| 名称 | 说明 |
|---|---|
| LoadFile(String, Evidence) |
已过时.
根据程序集的路径加载程序集,使用提供的证据加载程序集。 |
| LoadFile(String) |
加载指定路径上的程序集文件的内容。 |
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 不是当前加载的运行时的有效程序集。
securityEvidence 不是 null。 默认情况下,.NET Framework 4 中未启用旧 CAS 策略;如果未启用, securityEvidence 则必须 null为 。
注解
使用该方法 LoadFile 加载和检查具有相同标识的程序集,但位于不同的路径中。 LoadFile 不会将 LoadFrom 文件加载到上下文中,也不会像该方法那样使用加载路径 LoadFrom 解析依赖项。 LoadFile 在此有限方案中非常有用,因为 LoadFrom 不能用于加载具有相同标识但不同路径的程序集;它将仅加载第一个此类程序集。
请参阅 <loadFromRemoteSources> 从远程位置加载程序集。
适用于
LoadFile(String)
- Source:
- Assembly.cs
- Source:
- Assembly.cs
- Source:
- Assembly.cs
- Source:
- Assembly.cs
- Source:
- Assembly.cs
加载指定路径上的程序集文件的内容。
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
参数
- path
- String
要加载的文件的完全限定路径。
返回
加载的程序集。
- 属性
例外
该 path 参数不是绝对路径。
参数 path 为 null.
参数 path 为空字符串(“”)或不存在。
path 不是当前加载的运行时的有效程序集。
注解
此 API 存在于 .NET Core 中,以便兼容,但建议改用 AssemblyLoadContext 重载。
该程序集将加载到为此创建的新 AssemblyLoadContext 中。 有关程序集加载的详细信息,请参阅 托管程序集加载算法。
使用该方法 LoadFile 加载和检查具有相同标识的程序集,但位于不同的路径中。 LoadFile 不会将文件加载到从上下文中加载,也不会像该方法那样使用加载路径 LoadFrom 解析依赖项。 LoadFile 在此有限方案中非常有用,因为 LoadFrom 不能用于加载具有相同标识但不同路径的程序集;它将仅加载第一个此类程序集。
仅限 .NET Framework: 请参阅 <loadFromRemoteSources> 从远程位置加载程序集。