Assembly.ReflectionOnlyLoadFrom(String) Method


将给定路径的程序集加载到只反射上下文中。Loads an assembly into the reflection-only context, given its path.

 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



包含程序集清单的文件的路径。The path of the file that contains the manifest of the 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 版或更高版本,而 assemblyFile 是用更高版本编译的。Version 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. 若要执行该代码,请加载具有 LoadFile 方法的程序集。To execute the code, load the assembly with the LoadFile method.

assemblyFile 参数必须引用没有转义符的 URI。The assemblyFile parameter must refer to a URI without escape characters. 此方法为 URI 中的所有无效字符提供转义符。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.

Applies to