AppDomain.ReflectionOnlyAssemblyResolve 事件

定义

当程序集的解析在仅限反射的上下文中失败时发生。Occurs when the resolution of an assembly fails in the reflection-only context.

public:
 event ResolveEventHandler ^ ReflectionOnlyAssemblyResolve;
public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
[add: System.Security.SecurityCritical]
[remove: System.Security.SecurityCritical]
public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
member this.ReflectionOnlyAssemblyResolve : ResolveEventHandler 
[<add: System.Security.SecurityCritical>]
[<remove: System.Security.SecurityCritical>]
member this.ReflectionOnlyAssemblyResolve : ResolveEventHandler 
Public Custom Event ReflectionOnlyAssemblyResolve As ResolveEventHandler 
Public Event ReflectionOnlyAssemblyResolve As ResolveEventHandler 

事件类型

ResolveEventHandler
属性

注解

在仅反射上下文中,不会自动解析依赖项。In the reflection-only context, dependencies are not resolved automatically. 此事件的处理程序必须预加载或返回这些事件。They must be preloaded or returned by the handler for this event. 当程序集具有尚未加载到仅反射上下文中的依赖项时,将引发此事件。This event is raised when an assembly has a dependency that is not already loaded into the reflection-only context. 缺少的依赖项由属性指定 ResolveEventArgs.NameThe missing dependency is specified by the ResolveEventArgs.Name property. ResolveEventHandler此事件的必须返回满足依赖项的程序集。The ResolveEventHandler for this event must return an assembly that satisfies the dependency. 返回的程序集必须加载到仅反射上下文中。The assembly that is returned must be loaded into the reflection-only context.

重要

仅当要加载到仅反射上下文中的程序集缺少依赖项时才引发此事件 (例如,通过使用 Assembly.ReflectionOnlyLoad 方法) 。This event is raised only for missing dependencies of the assembly that you are loading into the reflection-only context (for example, by using the Assembly.ReflectionOnlyLoad method). 如果找不到正在加载的程序集,则不会引发此方法。It is not raised if the assembly that you are loading cannot be found.

从开始 .NET Framework 4.NET Framework 4ResolveEventArgs.RequestingAssembly 属性返回请求未能解析程序集加载的程序集。Beginning with the .NET Framework 4.NET Framework 4, the ResolveEventArgs.RequestingAssembly property returns the assembly that requested the assembly load that could not be resolved. 如果有多个可用版本,知道发出请求的程序集的标识可能会很有用。Knowing the identity of the requesting assembly might be useful in identifying the correct version of the dependency, if more than one version is available. 有关详细信息,请参阅 ResolveEventArgs.RequestingAssemblyFor more information, see ResolveEventArgs.RequestingAssembly.

对于此事件,属性将在 ResolveEventArgs.Name 应用策略之前返回程序集名称。For this event, the ResolveEventArgs.Name property returns the assembly name before policy is applied.

有关处理事件的详细信息,请参阅 处理和引发事件For more information about handling events, see Handling and Raising Events.

适用于

另请参阅