Dependency loading in .NET Core

本文内容

Every .NET Core application has dependencies. Even the simple hello world app has dependencies on portions of the .NET Core class libraries.

Understanding .NET Core default assembly loading logic can help understanding and debugging typical deployment issues.

In some applications, dependencies are dynamically determined at runtime. In these situations, it's critical to understand how managed assemblies and unmanaged dependencies are loaded.

Understanding AssemblyLoadContext

The AssemblyLoadContext API is central to the .NET Core loading design. The Understanding AssemblyLoadContext article provides a conceptual overview to the design.

Loading details

The loading algorithm details are covered briefly in several articles:

Create a .NET Core application with plugins

The tutorial Create a .NET Core application with plugins describes how to create a custom AssemblyLoadContext. It uses an AssemblyDependencyResolver to resolve the dependencies of the plugin. The tutorial correctly isolates the plugin's dependencies from the hosting application.

How to use and debug assembly unloadability in .NET Core

The How to use and debug assembly unloadability in .NET Core article is a step-by-step tutorial. It shows how to load a .NET Core application, execute, and then unload it. The article also provides debugging tips.