AssemblyLoadContext.Resolving 事件


在尝试加载到此程序集加载上下文时,程序集解析失败时发生。Occurs when the resolution of an assembly fails when attempting to load into this assembly load context.

 event Func<System::Runtime::Loader::AssemblyLoadContext ^, System::Reflection::AssemblyName ^, System::Reflection::Assembly ^> ^ Resolving;
public event Func<System.Runtime.Loader.AssemblyLoadContext,System.Reflection.AssemblyName,System.Reflection.Assembly?>? Resolving;
public event Func<System.Runtime.Loader.AssemblyLoadContext,System.Reflection.AssemblyName,System.Reflection.Assembly> Resolving;
member this.Resolving : Func<System.Runtime.Loader.AssemblyLoadContext, System.Reflection.AssemblyName, System.Reflection.Assembly> 
Public Custom Event Resolving As Func(Of AssemblyLoadContext, AssemblyName, Assembly) 
Public Event Resolving As Func(Of AssemblyLoadContext, AssemblyName, Assembly) 




此事件的处理程序负责返回指定的程序集; null 如果程序集未被识别,则为返回。It is the responsibility of the handler for this event to return the assembly that is specified, or to return null if the assembly is not recognized.


如果为此事件注册了多个事件处理程序,则将按顺序调用事件处理程序,直到事件处理程序返回一个不为的值 nullIf more than one event handler is registered for this event, the event handlers are called in order until an event handler returns a value that isn't null. 后续事件处理程序将被忽略。Subsequent event handlers are ignored.

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

值得注意的是,可以在任何情况下为此事件添加处理程序 AssemblyLoadContext ,包括默认上下文。It is noteworthy that a handler can be added for this event on any AssemblyLoadContext, including the default context.