public DefaultAssemblyLoadContext( IAssemblyLoadOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider hostTypesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider) { this.options = options; this.hostFrameworkProvider = hostFrameworkProvider; this.hostTypesProvider = hostTypesProvider; this.remoteTypesProvider = remoteTypesProvider; this.dependencyPathProvider = dependencyPathProvider; this.probingPathsProvider = probingPathsProvider; this.runtimePlatformContext = runtimePlatformContext; this.depsFileProvider = depsFileProvider; this.pluginDependencyResolver = pluginDependencyResolver; this.nativeAssemblyUnloader = nativeAssemblyUnloader; this.assemblyLoadStrategyProvider = assemblyLoadStrategyProvider; this.loadedNativeLibraries = new ConcurrentDictionary <string, IntPtr>(); }
protected virtual void Dispose(bool disposing) { if (!this.disposed && disposing) { this.disposing = true; GC.Collect(); GC.WaitForPendingFinalizers(); this.hostTypesProvider = null; this.remoteTypesProvider = null; this.dependencyPathProvider = null; this.probingPathsProvider = null; this.runtimePlatformContext = null; this.depsFileProvider = null; this.pluginDependencyResolver = null; this.pluginDependencyContext = null; this.assemblyLoadStrategy = null; // Unload any loaded native assemblies foreach (var nativeAssembly in this.loadedNativeLibraries) { this.nativeAssemblyUnloader.UnloadNativeAssembly(nativeAssembly.Key, nativeAssembly.Value); } this.loadedNativeLibraries = null; this.nativeAssemblyUnloader = null; } this.disposed = true; }
public NetworkAssemblyLoadContext( IPluginLogger <T> logger, INetworkAssemblyLoaderOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider <T> hostTypesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider, IHttpClientFactory httpClientFactory, ITempPathProvider <T> tempPathProvider) : base( logger, options, hostFrameworkProvider, hostTypesProvider, remoteTypesProvider, dependencyPathProvider, probingPathsProvider, runtimePlatformContext, depsFileProvider, pluginDependencyResolver, nativeAssemblyUnloader, assemblyLoadStrategyProvider ) { this.httpClient = httpClientFactory.CreateClient(); this.baseUrl = options.BaseUrl; this.tempPathProvider = tempPathProvider; }
public DefaultAssemblyLoaderWithNativeResolver( IPluginLogger <T> logger, IAssemblyLoadOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider <T> hostTypesProvider, IDowngradableDependenciesProvider <T> downgradableDependenciesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider) : base() { this.logger = logger; this.options = options; this.hostFrameworkProvider = hostFrameworkProvider; this.hostTypesProvider = hostTypesProvider; this.downgradableDependenciesProvider = downgradableDependenciesProvider; this.remoteTypesProvider = remoteTypesProvider; this.dependencyPathProvider = dependencyPathProvider; this.probingPathsProvider = probingPathsProvider; this.runtimePlatformContext = runtimePlatformContext; this.depsFileProvider = depsFileProvider; this.pluginDependencyResolver = pluginDependencyResolver; this.nativeAssemblyUnloader = nativeAssemblyUnloader; this.assemblyLoadStrategyProvider = assemblyLoadStrategyProvider; }
public DefaultAssemblyLoadContextWithNativeResolver( IAssemblyLoadOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider hostTypesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider ) : base( options, hostFrameworkProvider, hostTypesProvider, remoteTypesProvider, dependencyPathProvider, probingPathsProvider, runtimePlatformContext, depsFileProvider, pluginDependencyResolver, nativeAssemblyUnloader, assemblyLoadStrategyProvider ) { }
public FunctionPluginLoaderOptions( IPluginLoadOptions <IHelloPlugin> helloPluginLoadOptions, IPluginLogger <IHelloPlugin> pluginLogger, IPluginPathProvider <IHelloPlugin> pluginPathProvider, IHostTypesProvider <IHelloPlugin> hostTypesProvider, IRemoteTypesProvider <IHelloPlugin> remoteTypesProvider, IRuntimePlatformContext runtimePlatformContext, IHostFrameworkProvider hostFrameworkProvider, IDependencyPathProvider <IHelloPlugin> dependencyPathProvider, IProbingPathsProvider <IHelloPlugin> probingPathsProvider, IPluginDependencyResolver <IHelloPlugin> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, ITempPathProvider <IHelloPlugin> tempPathProvider, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider, IPluginServerOptions pluginServerOptions, IHttpClientFactory httpFactory) { this.helloPluginLoadOptions = helloPluginLoadOptions; this.pluginLogger = pluginLogger; this.pluginPathProvider = pluginPathProvider; this.hostTypesProvider = hostTypesProvider; this.remoteTypesProvider = remoteTypesProvider; this.runtimePlatformContext = runtimePlatformContext; this.hostFrameworkProvider = hostFrameworkProvider; this.dependencyPathProvider = dependencyPathProvider; this.probingPathsProvider = probingPathsProvider; this.pluginDependencyResolver = pluginDependencyResolver; this.nativeAssemblyUnloader = nativeAssemblyUnloader; this.tempPathProvider = tempPathProvider; this.assemblyLoadStrategyProvider = assemblyLoadStrategyProvider; this.pluginServerOptions = pluginServerOptions; this.httpFactory = httpFactory; }
public NetworkAssemblyLoader( IPluginLogger <T> logger, INetworkAssemblyLoaderOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider <T> hostTypesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider, ITempPathProvider <T> tempPathProvider, IHttpClientFactory httpClientFactory ) { this.logger = logger; this.options = options; this.hostFrameworkProvider = hostFrameworkProvider; this.hostTypesProvider = hostTypesProvider; this.remoteTypesProvider = remoteTypesProvider; this.dependencyPathProvider = dependencyPathProvider; this.probingPathsProvider = probingPathsProvider; this.runtimePlatformContext = runtimePlatformContext; this.depsFileProvider = depsFileProvider; this.pluginDependencyResolver = pluginDependencyResolver; this.nativeAssemblyUnloader = nativeAssemblyUnloader; this.assemblyLoadStrategyProvider = assemblyLoadStrategyProvider; this.tempPathProvider = tempPathProvider; this.httpClientFactory = httpClientFactory; }
public DefaultAssemblyLoaderWithNativeResolver( IAssemblyLoadOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider hostTypesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider) { this.loadContext = new DefaultAssemblyLoadContextWithNativeResolver <T>( options, hostFrameworkProvider, hostTypesProvider, remoteTypesProvider, dependencyPathProvider, probingPathsProvider, runtimePlatformContext, depsFileProvider, pluginDependencyResolver, nativeAssemblyUnloader, assemblyLoadStrategyProvider ); this.assemblyLoadContextReference = new System.WeakReference(this.loadContext); }
public DefaultAssemblyLoadContext( IPluginLogger <T> logger, IAssemblyLoadOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider <T> hostTypesProvider, IDowngradableDependenciesProvider <T> downgradableDependenciesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider) #if NETCORE3_0 || NETCORE3_1 : base(options.UseCollectibleAssemblies) #endif { this.logger = logger; this.options = options; this.hostFrameworkProvider = hostFrameworkProvider; this.hostTypesProvider = hostTypesProvider; this.downgradableDependenciesProvider = downgradableDependenciesProvider; this.remoteTypesProvider = remoteTypesProvider; this.dependencyPathProvider = dependencyPathProvider; this.probingPathsProvider = probingPathsProvider; this.runtimePlatformContext = runtimePlatformContext; this.depsFileProvider = depsFileProvider; this.pluginDependencyResolver = pluginDependencyResolver; this.nativeAssemblyUnloader = nativeAssemblyUnloader; this.assemblyLoadStrategyProvider = assemblyLoadStrategyProvider; this.loadedNativeLibraries = new ConcurrentDictionary <string, IntPtr>(); this.loadedPlugins = new ConcurrentBag <string>(); this.assemblyReferences = new ConcurrentBag <WeakReference>(); }
public NetworkAssemblyLoader( INetworkAssemblyLoaderOptions <T> options, IHostFrameworkProvider hostFrameworkProvider, IHostTypesProvider hostTypesProvider, IRemoteTypesProvider <T> remoteTypesProvider, IDependencyPathProvider <T> dependencyPathProvider, IProbingPathsProvider <T> probingPathsProvider, IRuntimePlatformContext runtimePlatformContext, IDepsFileProvider <T> depsFileProvider, IPluginDependencyResolver <T> pluginDependencyResolver, INativeAssemblyUnloader nativeAssemblyUnloader, IAssemblyLoadStrategyProvider assemblyLoadStrategyProvider, ITempPathProvider <T> tempPathProvider, IHttpClientFactory httpClientFactory ) { this.loadContext = new NetworkAssemblyLoadContext <T>( options, hostFrameworkProvider, hostTypesProvider, remoteTypesProvider, dependencyPathProvider, probingPathsProvider, runtimePlatformContext, depsFileProvider, pluginDependencyResolver, nativeAssemblyUnloader, assemblyLoadStrategyProvider, httpClientFactory, tempPathProvider ); this.assemblyLoadContextReference = new System.WeakReference(this.loadContext); }
protected virtual void Dispose(bool disposing) { if (!this.disposed && disposing) { this.disposing = true; GC.Collect(); GC.WaitForPendingFinalizers(); if (this.assemblyReferences != null) { foreach (var reference in this.assemblyReferences) { // https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability#use-collectible-assemblyloadcontext for (int i = 0; reference.IsAlive && (i < 10); i++) { GC.Collect(); GC.WaitForPendingFinalizers(); } } } // Unload any loaded native assemblies foreach (var nativeAssembly in this.loadedNativeLibraries) { this.nativeAssemblyUnloader.UnloadNativeAssembly(nativeAssembly.Key, nativeAssembly.Value); } this.loadedPlugins.Clear(); this.assemblyReferences.Clear(); this.loadedNativeLibraries.Clear(); this.pluginDependencyContext?.Dispose(); this.pluginDependencyResolver?.Dispose(); this.resolver?.Dispose(); this.resolver = null; this.loadedNativeLibraries = null; this.loadedPlugins = null; this.assemblyReferences = null; this.assemblyLoadStrategy = null; this.pluginDependencyContext = null; this.pluginDependencyResolver = null; this.fullPathToPluginAssembly = null; this.initialPluginLoadDirectory = null; this.pluginPlatformVersion = null; this.nativeAssemblyUnloader = null; this.pluginDependencyResolverFactory = null; this.assemblyLoadStrategyFactory = null; this.assemblyDependencyResolverFactory = null; this.fileSystemUtilities = null; this.runtimeDefaultAssemblyLoadContext = null; this.pluginDependencyContextProvider = null; } this.disposed = true; }
protected virtual void Dispose(bool disposing) { if (!this.disposed && disposing) { this.disposing = true; GC.Collect(); GC.WaitForPendingFinalizers(); this.hostTypesProvider = null; this.remoteTypesProvider = null; this.dependencyPathProvider = null; this.probingPathsProvider = null; this.runtimePlatformContext = null; this.depsFileProvider = null; this.pluginDependencyResolver = null; this.pluginDependencyContext = null; this.assemblyLoadStrategy = null; if (this.assemblyReferences != null) { foreach (var reference in this.assemblyReferences) { // https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability#use-collectible-assemblyloadcontext for (int i = 0; reference.IsAlive && (i < 10); i++) { GC.Collect(); GC.WaitForPendingFinalizers(); } } } this.loadedPlugins.Clear(); this.loadedPlugins = null; this.assemblyReferences.Clear(); this.assemblyReferences = null; // Unload any loaded native assemblies foreach (var nativeAssembly in this.loadedNativeLibraries) { this.nativeAssemblyUnloader.UnloadNativeAssembly(nativeAssembly.Key, nativeAssembly.Value); } this.loadedNativeLibraries = null; this.nativeAssemblyUnloader = null; this.options = null; } this.disposed = true; }
public DefaultAssemblyLoadContext(Func <INativeAssemblyUnloader> nativeAssemblyUnloaderFactory, Func <IPluginDependencyResolver> pluginDependencyResolverFactory, Func <IAssemblyLoadStrategy> assemblyLoadStrategyFactory, Func <string, IAssemblyDependencyResolver> assemblyDependencyResolverFactory, Func <IFileSystemUtilities> fileSystemUtilitiesFactory, Func <IRuntimeDefaultAssemblyContext> runtimeDefaultAssemblyLoadContextFactory, Func <IPluginDependencyContextProvider> pluginDependencyContextProviderFactory) { this.nativeAssemblyUnloader = nativeAssemblyUnloaderFactory.ThrowIfNull(nameof(nativeAssemblyUnloaderFactory))(); this.pluginDependencyResolverFactory = pluginDependencyResolverFactory.ThrowIfNull(nameof(pluginDependencyResolverFactory)); this.assemblyLoadStrategyFactory = assemblyLoadStrategyFactory.ThrowIfNull(nameof(assemblyLoadStrategyFactory)); this.assemblyDependencyResolverFactory = assemblyDependencyResolverFactory.ThrowIfNull(nameof(assemblyDependencyResolverFactory)); this.fileSystemUtilities = fileSystemUtilitiesFactory.ThrowIfNull(nameof(fileSystemUtilitiesFactory))(); this.runtimeDefaultAssemblyLoadContext = runtimeDefaultAssemblyLoadContextFactory.ThrowIfNull(nameof(runtimeDefaultAssemblyLoadContextFactory))(); this.pluginDependencyContextProvider = pluginDependencyContextProviderFactory.ThrowIfNull(nameof(pluginDependencyContextProviderFactory))(); this.loadedNativeLibraries = new ConcurrentDictionary <string, IntPtr>(); this.loadedPlugins = new ConcurrentBag <string>(); this.assemblyReferences = new ConcurrentBag <WeakReference>(); }