Managed assemblies are located and loaded with an algorithm that has various stages.
All managed assemblies except satellite assemblies and WinRT
assemblies use the same algorithm.
The most common mechanism to trigger a managed assembly load is a static assembly reference. These references are inserted by the compiler whenever code uses a type defined in another assembly. These assemblies are loaded (load-by-name
) as needed by the runtime. The exact timing of when the static assembly references are loaded is unspecified. It can vary between runtime versions and is influenced by optimizations like inlining.
The direct use of the following APIs will also trigger loads:
API DescriptionActive
AssemblyLoadContext AssemblyLoadContext.LoadFromAssemblyName Load-by-name
The this instance. AssemblyLoadContext.LoadFromAssemblyPath
Load-by-name
. Inferred from caller.
Load-by-name
. Inferred from caller.
assemblyResolver
argument. Assembly.GetType If type name
describes an assembly qualified generic type, trigger a Load-by-name
. Inferred from caller.
Load-by-name
. Inferred from caller.
The following algorithm describes how the runtime loads a managed assembly.
Determine the active
AssemblyLoadContext.
active
AssemblyLoadContext is the instance that loaded the referring assembly.active
AssemblyLoadContext explicit.active
AssemblyLoadContext. For these APIs, the AssemblyLoadContext.CurrentContextualReflectionContext property is used. If its value is null
, then the inferred AssemblyLoadContext instance is used.For the Load-by-name
methods, the active
AssemblyLoadContext loads the assembly in the following priority order:
cache-by-name
.cache-by-name
.For the other types of loads, the active
AssemblyLoadContext loads the assembly in the following priority order:
cache-by-name
.active
AssemblyLoadContext instance's cache-by-name
.In either case, if an assembly is newly loaded, then the AppDomain.AssemblyLoad event is raised.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. Additional resources In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4