Assembly.ReflectionOnlyLoadFrom(String) 方法

定義

將組件載入僅限反映的內容中,並指定其路徑。Loads an assembly into the reflection-only context, given its path.

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

參數

assemblyFile
String

檔案的路徑,該檔案包含組件的資訊清單。The path of the file that contains the manifest of the assembly.

傳回

Assembly

載入的組件。The loaded assembly.

例外狀況

assemblyFilenullassemblyFile is null.

找不到 assemblyFile,或您想載入的模組並未指定檔案的副檔名。assemblyFile is not found, or the module you are trying to load does not specify a file name extension.

找到assemblyFile ,但無法載入。assemblyFile is found, but could not be loaded.

assemblyFile 不是有效的組件。assemblyFile is not a valid assembly.

-或--or-

目前載入的是通用語言執行平台 2.0 版或更新版本,且已使用更新的版本來編譯 assemblyFileVersion 2.0 or later of the common language runtime is currently loaded and assemblyFile was compiled with a later version.

指定了並非以 "file://" 開頭的程式碼基底,且沒有必要的 WebPermissionA codebase that does not start with "file://" was specified without the required WebPermission.

組件名稱超過系統定義的長度上限。The assembly name exceeds the system-defined maximum length.

assemblyFile 為空字串 ("")。assemblyFile is an empty string ("").

僅限 .NET Core:不支援此成員。.NET Core only: This member is not supported.

備註

相依性不會自動載入至僅限反映的內容中。Dependencies are not automatically loaded into the reflection-only context. 若要自動載入相依性,請處理 ReflectionOnlyAssemblyResolve 事件,然後在事件處理常式中載入相依性。To automatically load dependencies, handle the ReflectionOnlyAssemblyResolve event and load the dependency in the event handler.

您無法從已載入僅限反映內容的元件中執行程式碼。You cannot execute code from an assembly that has been loaded into the reflection-only context. 若要執行程式碼,請使用方法載入元件 LoadFileTo execute the code, load the assembly with the LoadFile method.

assemblyFile參數必須參考不含 escape 字元的 URI。The assemblyFile parameter must refer to a URI without escape characters. 這個方法會為 URI 中的所有無效字元提供 escape 字元。This method supplies escape characters for all invalid characters in the URI.

為指定的路徑 assemblyFile 相對於目前的目錄。The path specified for assemblyFile is relative to the current directory. 元件會載入至呼叫端的網域。The assembly is loaded into the domain of the caller.

僅限反映的內容與其他內容並無不同。The reflection-only context is no different from other contexts. 只有卸載應用程式域,才能卸載載入內容中的元件。Assemblies that are loaded into the context can be unloaded only by unloading the application domain.

適用於