/// <summary> /// Resolves the supplied assembly name to an assembly. If an assembly was previously bound by to this name, that assembly is returned. /// Otherwise, the MetadataLoadContext calls the specified MetadataAssemblyResolver. If the resolver returns null, this method throws a FileNotFoundException. /// /// Note that this behavior matches the behavior of AssemblyLoadContext.LoadFromAssemblyName() resolve event but does not match the behavior of /// Assembly.ReflectionOnlyLoad(). (the latter gives up without raising its resolve event.) /// </summary> public Assembly LoadFromAssemblyName(AssemblyName assemblyName) { if (assemblyName is null) { throw new ArgumentNullException(nameof(assemblyName)); } if (IsDisposed) { throw new ObjectDisposedException(nameof(MetadataLoadContext)); } RoAssemblyName refName = assemblyName.ToRoAssemblyName(); return(ResolveAssembly(refName)); }
/// <summary> /// Resolves the supplied assembly name to an assembly. If an assembly was previously bound by to this name, that assembly is returned. /// Otherwise, the TypeLoader raises the Resolving event. If the event handler returns null, this method throws a FileNotFoundException. /// /// Note that this behavior matches the behavior of AssemblyLoadContext.LoadFromAssemblyName() but does not match the behavior of /// Assembly.ReflectionOnlyLoad(). (the latter gives up without raising the resolve event.) /// </summary> public Assembly LoadFromAssemblyName(AssemblyName assemblyName) { if (IsDisposed) { throw new ObjectDisposedException(nameof(TypeLoader)); } if (assemblyName == null) { throw new ArgumentNullException(nameof(assemblyName)); } RoAssemblyName refName = assemblyName.ToRoAssemblyName(); return(ResolveAssembly(refName)); }