• Articles
  • Api Documentation
Show / Hide Table of Contents
  • Dapplo.Addons
    • IAction
    • IApplicationBootstrapper
    • IAsyncShutdownAction
    • IAsyncStartupAction
    • IBootstrapper
    • IDependencyProvider
    • IMefServiceLocator
    • IModule
    • IServiceExporter
    • IServiceRepository
    • IShutdownAction
    • IShutdownMetadata
    • IShutdownModule
    • IStartupAction
    • IStartupMetadata
    • IStartupModule
    • ModuleAttribute
    • ShutdownActionAttribute
    • StartupActionAttribute
    • StartupException
  • Dapplo.Addons.Bootstrapper
    • ApplicationBootstrapper
    • CompositionBootstrapper
    • ResourceMutex
    • StartupShutdownBootstrapper
  • Dapplo.Addons.Bootstrapper.Internal
    • CompressionTypes
    • StreamExtensions
  • Dapplo.Addons.Bootstrapper.Resolving
    • AssemblyResolver
    • EmbeddedResources
    • FileLocations
    • FileTools

Class AssemblyResolver

This is a static Assembly resolver and Assembly loader It takes care of caching and prevents that an Assembly is loaded twice (which would cause issues!)

Inheritance
System.Object
AssemblyResolver
Namespace:Dapplo.Addons.Bootstrapper.Resolving
Assembly:Dapplo.Addons.Bootstrapper.dll
Syntax
public static class AssemblyResolver : object

Properties

| Improve this Doc View Source

AssemblyCache

IEnumerable with all cached assemblies

Declaration
public static IEnumerable<Assembly> AssemblyCache { get; }
Property Value
Type Description
IEnumerable<Assembly>
| Improve this Doc View Source

CheckEmbeddedResourceNameAgainstCache

Defines if before loading an assembly from a resource, the Assembly names from the cache are checked against the resource name. This speeds up the loading, BUT might have a problem that an assembly "x.y.z.dll" is skipped as "y.z.dll" was already loaded.

Declaration
public static bool CheckEmbeddedResourceNameAgainstCache { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Directories

Directories which this AssemblyResolver uses to find assemblies

Declaration
public static IEnumerable<string> Directories { get; }
Property Value
Type Description
IEnumerable<System.String>
| Improve this Doc View Source

Extensions

The extensions used for finding assemblies, you can add your own. Extensions can end on .gz when such a file/resource is used it will automatically be decompresed

Declaration
public static ISet<string> Extensions { get; }
Property Value
Type Description
ISet<System.String>
| Improve this Doc View Source

ResolveEmbeddedBeforeFiles

Defines if the resolving is first loading internal files, if nothing was found check the file system There might be security reasons for not doing this.

Declaration
public static bool ResolveEmbeddedBeforeFiles { get; set; }
Property Value
Type Description
System.Boolean

Methods

| Improve this Doc View Source

AddDirectory(String)

Add the specified directory, by converting it to an absolute directory

Declaration
public static void AddDirectory(string directory)
Parameters
Type Name Description
System.String directory

Directory to add for resolving

| Improve this Doc View Source

FindAssemblies(IEnumerable<String>, IEnumerable<String>)

Find the specified assemblies from a manifest resource or from the file system. It is possible to use wildcards but the first match will be loaded!

Declaration
public static IEnumerable<Assembly> FindAssemblies(IEnumerable<string> assemblyNames, IEnumerable<string> extensions = null)
Parameters
Type Name Description
IEnumerable<System.String> assemblyNames

IEnumerable with the assembly names, e.g. from AssemblyName.Name, do not specify an extension

IEnumerable<System.String> extensions

IEnumerable with extensions to look for, defaults will be set if null was passed

Returns
Type Description
IEnumerable<Assembly>

IEnumerable with Assembly

| Improve this Doc View Source

FindAssembly(String, IEnumerable<String>)

Find the specified assembly from a manifest resource or from the file system. It is possible to use wildcards but the first match will be loaded!

Declaration
public static Assembly FindAssembly(string assemblyName, IEnumerable<string> extensions = null)
Parameters
Type Name Description
System.String assemblyName

string with the assembly name, e.g. from AssemblyName.Name, do not specify an extension

IEnumerable<System.String> extensions

IEnumerable with extensions to look for, defaults will be set if null was passed

Returns
Type Description
Assembly

Assembly or null

| Improve this Doc View Source

LoadAssemblyFromFile(String)

Simple method to load an assembly from a file path (or returned a cached version). If it was loaded new, it will be added to the cache

Declaration
public static Assembly LoadAssemblyFromFile(string filepath)
Parameters
Type Name Description
System.String filepath

string with the path to the file

Returns
Type Description
Assembly

Assembly

| Improve this Doc View Source

LoadAssemblyFromFileSystem(IEnumerable<String>, String, IEnumerable<String>)

Load the specified assembly from the specified directories, or return null

Declaration
public static Assembly LoadAssemblyFromFileSystem(IEnumerable<string> directories, string assemblyName, IEnumerable<string> extensions = null)
Parameters
Type Name Description
IEnumerable<System.String> directories

IEnumerable with directories

System.String assemblyName

string with the name without path

IEnumerable<System.String> extensions

IEnumerable with extensions to look for, defaults will be set if null was passed

Returns
Type Description
Assembly

Assembly

| Improve this Doc View Source

LoadAssemblyFromFileSystem(String, IEnumerable<String>)

Load the specified assembly from the ResolveDirectories, or return null

Declaration
public static Assembly LoadAssemblyFromFileSystem(string assemblyName, IEnumerable<string> extensions = null)
Parameters
Type Name Description
System.String assemblyName

string with the name without path

IEnumerable<System.String> extensions

IEnumerable with extensions to look for, defaults will be set if null was passed

Returns
Type Description
Assembly

Assembly

| Improve this Doc View Source

LoadAssemblyFromStream(Stream, CompressionTypes, Boolean)

Simple method to load an assembly from a stream

Declaration
public static Assembly LoadAssemblyFromStream(Stream assemblyStream, CompressionTypes compressionType = CompressionTypes.None, bool checkCache = false)
Parameters
Type Name Description
Stream assemblyStream

Stream

CompressionTypes compressionType

specify the compression type for the stream

System.Boolean checkCache

specify if the cache needs to be checked, this costs performance

Returns
Type Description
Assembly

Assembly or null when the stream is null

| Improve this Doc View Source

LoadEmbeddedAssembly(Assembly, String)

Load the specified assembly from an embedded (manifest) resource, or return null

Declaration
public static Assembly LoadEmbeddedAssembly(this Assembly assembly, string resourceName)
Parameters
Type Name Description
Assembly assembly

Assembly to load the resource from

System.String resourceName

Name of the embedded resource for the assembly to load

Returns
Type Description
Assembly

Assembly

| Improve this Doc View Source

LoadEmbeddedAssembly(String, IEnumerable<String>)

Load the specified assembly from a manifest resource, or return null

Declaration
public static Assembly LoadEmbeddedAssembly(string assemblyName, IEnumerable<string> extensions = null)
Parameters
Type Name Description
System.String assemblyName

string

IEnumerable<System.String> extensions

IEnumerable with extensions to look for, defaults will be set if null was passed

Returns
Type Description
Assembly

Assembly

| Improve this Doc View Source

Register(Assembly, String)

Extension to register an assembly to the AssemblyResolver, this is used for resolving embedded assemblies

Declaration
public static void Register(this Assembly assembly, string filepath = null)
Parameters
Type Name Description
Assembly assembly

Assembly

System.String filepath

Path to assembly, or null if it isn't loaded from the file system

| Improve this Doc View Source

RegisterAssemblyResolve()

Register AssemblyResolve on the current AppDomain

Declaration
public static IDisposable RegisterAssemblyResolve()
Returns
Type Description
IDisposable

IDisposable, when disposing this the event registration is removed

| Improve this Doc View Source

RegisterAssemblyResolve(AppDomain)

Register the AssemblyResolve event for the specified AppDomain This can be called multiple times, it detect this.

Declaration
public static IDisposable RegisterAssemblyResolve(this AppDomain appDomain)
Parameters
Type Name Description
AppDomain appDomain
Returns
Type Description
IDisposable

IDisposable, when disposing this the event registration is removed

| Improve this Doc View Source

UnregisterAssemblyResolve()

Unregister AssemblyResolve from the current AppDomain

Declaration
public static void UnregisterAssemblyResolve()
| Improve this Doc View Source

UnregisterAssemblyResolve(AppDomain)

Unregister the AssemblyResolve event for the specified AppDomain This can be called multiple times, it detect this.

Declaration
public static void UnregisterAssemblyResolve(this AppDomain appDomain)
Parameters
Type Name Description
AppDomain appDomain
  • Improve this Doc
  • View Source
Back to top Copyright © 2017 Dapplo