AppDomain.ReflectionOnlyAssemblyResolve AppDomain.ReflectionOnlyAssemblyResolve AppDomain.ReflectionOnlyAssemblyResolve AppDomain.ReflectionOnlyAssemblyResolve Event


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

 event ResolveEventHandler ^ ReflectionOnlyAssemblyResolve;
[add: System.Security.SecurityCritical]
[remove: System.Security.SecurityCritical]
public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
member this.ReflectionOnlyAssemblyResolve : ResolveEventHandler 
Public Event ReflectionOnlyAssemblyResolve As 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.Name属性指定。The 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 4从开始ResolveEventArgs.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.


需要对直接调用方的完全信任。requires full trust for the immediate caller. 部分受信任的或透明的代码不能使用此成员。This member cannot be used by partially trusted or transparent code.