Class AssemblyLoadContextExtensions
Extension methods to load assemblies from disk.
public static class AssemblyLoadContextExtensions
- Inheritance
-
AssemblyLoadContextExtensions
- Inherited Members
Methods
TryLoadFromAssembliesPath(AssemblyLoadContext, IEnumerable<string>)
Try to load the assemblies from the given file paths.
public static IEnumerable<Assembly> TryLoadFromAssembliesPath(this AssemblyLoadContext loader, IEnumerable<string> paths)
Parameters
loaderAssemblyLoadContextThe load context to use to load.
pathsIEnumerable<string>The list of assembly paths to load.
Returns
- IEnumerable<Assembly>
A collection of assemblies that could be loaded.
Remarks
SECURITY NOTE: Ensure that you trust those assemblies. You may introduce a security risk by running arbitrary code. If an assembly fails to load it will be silently skipped.
TryLoadFromAssemblyPath(AssemblyLoadContext, string)
Try to load the assembly from the given path.
public static Assembly? TryLoadFromAssemblyPath(this AssemblyLoadContext loader, string path)
Parameters
loaderAssemblyLoadContextThe assembly load context.
pathstringAssembly to load.
Returns
- Assembly
The load assembly or null on error.
TryLoadFromBaseLoadDirectory(AssemblyLoadContext)
Try to load every .NET assembly in the current domain base directory. This is usually the process path or the entry assembly path.
public static IEnumerable<Assembly> TryLoadFromBaseLoadDirectory(this AssemblyLoadContext loader)
Parameters
loaderAssemblyLoadContextThe load context to use to load.
Returns
- IEnumerable<Assembly>
A collection of assemblies that could be loaded.
Remarks
SECURITY NOTE: Ensure that you trust those assemblies. You may introduce a security risk by running arbitrary code. If an assembly fails to load it will be silently skipped.
TryLoadFromDirectory(AssemblyLoadContext, string, bool)
Try to load every .NET assembly from the given directory.
public static IEnumerable<Assembly> TryLoadFromDirectory(this AssemblyLoadContext loader, string directory, bool recursive)
Parameters
loaderAssemblyLoadContextThe load context to use to load.
directorystringThe directory to find assemblies.
recursiveboolValue indicating whether it should search all directories or only the top directory.
Returns
- IEnumerable<Assembly>
A collection of assemblies that could be loaded.
Remarks
SECURITY NOTE: Ensure that you trust those assemblies. You may introduce a security risk by running arbitrary code. If an assembly fails to load it will be silently skipped.