Table of Contents

Class AssemblyLoadContextExtensions

Namespace
Yarhl.Plugins
Assembly
Yarhl.Plugins.dll

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

loader AssemblyLoadContext

The load context to use to load.

paths IEnumerable<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

loader AssemblyLoadContext

The assembly load context.

path string

Assembly 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

loader AssemblyLoadContext

The 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

loader AssemblyLoadContext

The load context to use to load.

directory string

The directory to find assemblies.

recursive bool

Value 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.