/// <summary> /// The unloads and reloads the plugin assemblies. /// This method throws if <see cref="IsUnloadable" /> is <c>false</c>. /// </summary> public void Reload() { this.EnsureNotDisposed(); if (!this.IsUnloadable) { throw new InvalidOperationException("Reload cannot be used because IsUnloadable is false"); } this.context.Unload(); this.context = (ManagedLoadContext)this.contextBuilder.Build(); GC.Collect(); GC.WaitForPendingFinalizers(); }
/// <summary> /// Initializes a new instance of the <see cref="PluginLoader"/> class. /// </summary> /// <param name="config">The configuration for the plugin.</param> public PluginLoader(LoaderConfig config) { this.config = config ?? throw new ArgumentNullException(nameof(config)); this.contextBuilder = CreateLoadContextBuilder(config); this.context = (ManagedLoadContext)this.contextBuilder.Build(); }