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++可能会引发FileLoadExceptionReflecting 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.

适用于