Share via


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

無法載入找到的檔案。

-或-

僅 .NET Framework:path指定根據<loadFromRemoteSources>停用的位置。

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

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

備註

LoadFile使用方法來載入和檢查具有相同身分識別但位於不同路徑的元件。 LoadFile 不會將檔案載入至從內容載入,而且不會使用載入路徑解析相依性,如同方法一樣 LoadFromLoadFile 在此有限的案例中很有用,因為 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。 根據預設,舊版 CAS 原則不會在 .NET Framework 4 中啟用;如果未啟用,securityEvidence則必須是 null

備註

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

如需從遠端位置載入元件,請參閱 <loadFromRemoteSources>

適用於