Assembly.LoadFile 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
載入組合檔的內容。
多載
| 名稱 | Description |
|---|---|
| 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)
- 來源:
- Assembly.cs
- 來源:
- Assembly.cs
- 來源:
- Assembly.cs
- 來源:
- Assembly.cs
- 來源:
- 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 overloads。
組裝檔會載入為此目的建立的新 AssemblyLoadContext。 欲了解更多組裝裝載資訊,請參閱 管理組裝裝載演算法。
使用此 LoadFile 方法載入並檢查具有相同身份但位於不同路徑的組裝體。 LoadFile 不會將檔案載入 load-from,也不會像方法那樣 LoadFrom 透過載入路徑解決相依關係。 LoadFile 在此有限情境下 是有用的,因為 LoadFrom 無法用於載入具有相同身份但路徑不同的組裝體;它只會載入第一個此類組裝體。
僅限 .NET Framework: 請參閱 <loadFromRemoteSources> 從遠端地區裝載組件的資訊。