Assembly.LoadFile 方法

定義

載入組件檔案的內容。

多載

LoadFile(String)

載入指定路徑上組件檔案的內容。

LoadFile(String, Evidence)
已淘汰.

載入具有其路徑的元件,並使用提供的辨識項載入元件。

LoadFile(String)

來源:
Assembly.cs
來源:
Assembly.cs
來源:
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

無法載入找到的檔案。

-或-

已停用在遠端組件中執行程式碼的能力。 請參閱 <loadFromRemoteSources>

path 參數為空字串 ("") 或不存在。

path 不是目前載入運行時間的有效元件。

備註

LoadFile使用方法來載入和檢查具有相同身分識別但位於不同路徑的元件。 LoadFile 不會將檔案載入至從內容載入,而且不會使用載入路徑解析相依性,如同方法一樣 LoadFromLoadFile 在此有限的案例中很有用,因為 LoadFrom 無法用來載入具有相同身分識別但不同路徑的元件;它只會載入第一個這類元件。

從 .NET Framework 4 開始,如果path指定遠端位置中的元件,預設會停用元件載入,而 LoadFile 方法會擲回 FileLoadException。 若要啟用從遠端位置載入的程式代碼執行,您可以使用 <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 參數為空字串 ("") 或不存在。

無法載入找到的檔案。

-或-

已停用在遠端組件中執行程式碼的能力。 請參閱 <loadFromRemoteSources>

path 不是目前載入運行時間的有效元件。

securityEvidence 不是 null。 根據預設,在 .NET Framework 4 中未啟用舊版 CAS 原則;如果未啟用,securityEvidence則必須是 null

備註

LoadFile使用方法來載入和檢查具有相同身分識別但位於不同路徑的元件。 LoadFile 不會將檔案 LoadFrom 載入內容中,而且不會使用載入路徑解析相依性,如同方法一樣 LoadFromLoadFile 在此有限的案例中很有用,因為 LoadFrom 無法用來載入具有相同身分識別但不同路徑的元件;它只會載入第一個這類元件。

從 .NET Framework 4 開始,如果path指定遠端位置中的元件,預設會停用元件載入,而 LoadFile 方法會擲回 FileLoadException。 若要啟用從遠端位置載入的程式代碼執行,您可以使用 <loadFromRemoteSources> 組態專案。

適用於