Assembly.ReflectionOnlyLoad Assembly.ReflectionOnlyLoad Assembly.ReflectionOnlyLoad Assembly.ReflectionOnlyLoad Method

定义

将程序集加载到只反射上下文中,在只反射上下文中可以检查但不能执行程序集。Loads an assembly into the reflection-only context, where it can be examined but not executed.

重载

ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[])

加载来自基于通用对象文件格式 (COFF) 的映像的程序集,该映像包含已发出的程序集。Loads the assembly from a common object file format (COFF)-based image containing an emitted assembly. 程序集被加载到调用方的应用程序域的只反射上下文中。The assembly is loaded into the reflection-only context of the caller's application domain.

ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String)

将给定显示名称的程序集加载到只反射上下文中。Loads an assembly into the reflection-only context, given its display name.

ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[])

加载来自基于通用对象文件格式 (COFF) 的映像的程序集,该映像包含已发出的程序集。Loads the assembly from a common object file format (COFF)-based image containing an emitted assembly. 程序集被加载到调用方的应用程序域的只反射上下文中。The assembly is loaded into the reflection-only context of the caller's application domain.

public:
 static System::Reflection::Assembly ^ ReflectionOnlyLoad(cli::array <System::Byte> ^ rawAssembly);
public static System.Reflection.Assembly ReflectionOnlyLoad (byte[] rawAssembly);
static member ReflectionOnlyLoad : byte[] -> System.Reflection.Assembly
Public Shared Function ReflectionOnlyLoad (rawAssembly As Byte()) As Assembly

参数

rawAssembly
Byte[]

字节数组,它是包含已发出程序集的基于 COFF 的映像。A byte array that is a COFF-based image containing an emitted assembly.

返回

加载的程序集。The loaded assembly.

异常

rawAssembly 不是有效的程序集。rawAssembly is not a valid assembly.

-or- 当前加载的是公共语言运行时 2.0 版或更高版本,而 rawAssembly 是用更高的版本编译的。Version 2.0 or later of the common language runtime is currently loaded and rawAssembly was compiled with a later version.

无法加载 rawAssemblyrawAssembly cannot be loaded.

注解

不能执行加载到仅反射上下文中的程序集的代码。You cannot execute code from an assembly loaded into the reflection-only context. 若要执行代码, 还必须使用Load方法将程序集加载到执行上下文中。To execute code, the assembly must be loaded into the execution context as well, using the Load method.

仅反射上下文与其他上下文没有区别。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.

ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String)

将给定显示名称的程序集加载到只反射上下文中。Loads an assembly into the reflection-only context, given its display name.

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

参数

assemblyString
String String String String

程序集的显示名称,由 FullName 属性返回。The display name of the assembly, as returned by the FullName property.

返回

加载的程序集。The loaded assembly.

异常

assemblyString 为空字符串 ("")。assemblyString is an empty string ("").

assemblyString 未找到。assemblyString is not found.

assemblyString 已找到,但无法加载。assemblyString is found, but cannot be loaded.

assemblyString 不是有效的程序集。assemblyString is not a valid assembly.

- 或 --or- 当前加载的是公共语言运行时 2.0 版或更高版本,而 assemblyString 是用更高的版本编译的。Version 2.0 or later of the common language runtime is currently loaded and assemblyString was compiled with a later version.

注解

依赖项不会自动加载到仅反射上下文中。Dependencies are not automatically loaded into the reflection-only context.

不能执行加载到仅反射上下文中的程序集的代码。You cannot execute code from an assembly loaded into the reflection-only context. 若要执行代码, 还必须使用Load方法将程序集加载到执行上下文中。To execute code, the assembly must be loaded into the execution context as well, using the Load method.

是否将特定的权限授予程序集是基于证据的。Whether certain permissions are granted or not granted to an assembly is based on evidence. 程序集和安全证据合并的规则如下所示:The rules for assembly and security evidence merging are as follows:

备注

在中编译的可执行C++文件上进行FileLoadException反射可能会引发。Reflecting on executable files compiled in C++ might throw a FileLoadException. 这很可能是由于C++编译器从可执行文件中去除重定位地址或 .reloc 部分所致。This is most likely caused by the C++ compiler stripping the relocation addresses or the .reloc section from your executable file. 若要保留 .reloc 地址, 请指定/fixed:no链接的时间。To preserve the .reloc address, specify /fixed:no when you are linking.

仅反射上下文与其他上下文没有区别。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.

适用于