Dependo 1.3.0

dotnet add package Dependo --version 1.3.0
                    
NuGet\Install-Package Dependo -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dependo" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dependo" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Dependo" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dependo --version 1.3.0
                    
#r "nuget: Dependo, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dependo@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dependo&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Dependo&version=1.3.0
                    
Install as a Cake Tool

<img src="https://github.com/gordon-matt/Dependo/raw/master/_Misc/Logo.png" alt="Logo" width="250" />

Intro

Dependo is a library that let's you resolve dependencies from anywhere via a singleton call to DependoResolver.Instance. This is mostly useful for resolving dependencies in static classes, including extensions methods.

Additionally, there is an IDependencyRegistrar interface to let you register dependencies from anywhere, such as class libraries. If you need to take advantage of implementation-specific registration features, you can make use of the more specialized dependency registrar, such as IAutofacDependencyRegistrar, IDryIocDependencyRegistrar, etc.

Compile-time discovery

Finding those registrars used to reflect over every assembly already loaded in the process. Referencing a Dependo container package now generates that list while the project compiles.

The application project (the one with an entry point) writes a module initializer that loads each participating assembly and seals DependoCatalog. Library projects that contain an IDependencyRegistrar, or a concrete type exported with DependoExports, write their own initializer. After DependoCatalog is sealed, ITypeFinder answers those queries from the catalog. Published container packages carry the generator. A project reference does not, so attach Dependo.Generator with OutputItemType set to Analyzer.

IDependencyRegistrar and the container-specific registrar interfaces are always catalogued. For anything else a host discovers by scanning, mark the service once:

[assembly: Dependo.DependoExports(typeof(IStartupTask), typeof(ITask))]

Put that attribute on an assembly that implementors reference, or on each assembly that contains implementations. The generator only sees a project that references Dependo directly, because source generators do not flow through transitive packages. Types discovered this way still need a public or internal parameterless constructor when the host activates them itself.

Assemblies loaded after startup, such as plugins, are still reflected once, and only those assemblies. Framework assemblies that match the type finder's skip pattern are not. Hosts that load plugins themselves should turn off the extra pass that loads every DLL from the output folder:

DependoCatalog.ProbeBinFolder = false;

Set that before the container is built. Leave the default when plugins are discovered by probing the bin folder.

To skip more assemblies than the built-in list, add name prefixes before the container is built. A prefix matches the start of the assembly full name and is applied together with the type finder's skip pattern. The built-in prefixes, such as System and Microsoft, stay in place.

DependoCatalog.SkipAssembliesStartingWith("AWSSDK", "Azure", "Google", "Grpc");

To force the mode, set DependoCatalog to root, local, or off. off keeps the reflection scan.

Check the demo project for a clearer idea on how to use Dependo. Or for a more advanced example, see it being used in MantleCMS

NuGet Packages

Package Version Downloads
Dependo NuGet NuGet
Dependo.Autofac NuGet NuGet
Dependo.DotNetDefault NuGet NuGet
Dependo.DryIoc NuGet NuGet
Dependo.Lamar NuGet NuGet
Dependo.LightInject NuGet NuGet

Feature Support

The default .NET implementation suits most needs. You could start with that and then if more advanced features are required, simply swap out that implementation for another. Use the following table to help decide which is most suitable for your project.

Method Default .NET DI Autofac DryIoc Lamar LightInject
IsRegistered(Type serviceType) ✅ ✅ ✅ ✅ ✅
Resolve<T>() ✅ ✅ ✅ ✅ ✅
Resolve<T>(IDictionary<string, object> ctorArgs) ❌ ✅ ✅ ❌ ❌
object Resolve(Type type) ✅ ✅ ✅ ✅ ✅
T ResolveKeyed<T>(object key) ✅ ✅ ✅ ✅ ✅
T ResolveKeyed<T>(object key, IDictionary<string, object> ctorArgs) ❌ ✅ ✅ ❌ ❌
IEnumerable<T> ResolveAllKeyed<T>(object key) ✅ ✅ ❌ ❌ ❌
IEnumerable<T> ResolveAll<T>() ✅ ✅ ✅ ✅ ✅
IEnumerable<T> ResolveAllNamed<T> ✅ ✅ ❌ ❌ ❌
T ResolveNamed<T>(string name) ✅ ✅ ✅ ✅ ✅
T? ResolveUnregistered<T>() ✅ ✅ ✅ ✅ ✅
object ResolveUnregistered(Type type) ✅ ✅ ✅ ✅ ✅
bool TryResolve<T>(out T? instance) ✅ ✅ ✅ ✅ ✅
bool TryResolve(Type serviceType, out object? instance) ✅ ✅ ✅ ✅ ✅

Credits

I based the original version of this project on some code found in an old version of nopCommerce. They only used Autofac; I wanted it to be more generic for use in projects where the IOC container may need to be swapped out for another implementation.

Support

If you find this project useful, consider supporting its development.

<p align="center"> <a href="https://buymeacoffee.com/vnmatt"> <img src="https://github.com/gordon-matt/MyResume/blob/gh-pages/assets/images/BuyMeACoffee_Logo.png" alt="Buy Me a Coffee" height="40"> </a>    <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=gordon_matt%40live%2ecom&lc=AU&currency_code=AUD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"> <img src="https://github.com/gordon-matt/MyResume/blob/gh-pages/assets/images/PayPal_Logo.png" alt="Donate with PayPal" height="40"> </a> </p>

<p align="center"> Prefer using your phone? Scan the QR code: </p>

<p align="center"> <a href="https://buymeacoffee.com/vnmatt"> <img src="https://github.com/gordon-matt/MyResume/blob/gh-pages/assets/images/BuyMeACoffee_QR.png" alt="Buy Me a Coffee QR Code" width="180"> </a> </p>

<img src="https://komarev.com/ghpvc/?username=gordon-matt&label=GitHub%20Hits%20Since%202025-06-01%3A%20&color=ff0000&style=flat" alt="gordon-matt" />

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Dependo:

Package Downloads
Dependo.Autofac

Autofac implementation for Dependo

Dependo.DotNetDefault

.NET Default implementation for Dependo

Dependo.Lamar

Lamar implementation for Dependo

Dependo.DryIoc

DryIoc implementation for Dependo

MantleFramework.Infrastructure.Abstractions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 60 11/18/2026
1.2.3 154 11/5/2026
1.2.2 175 10/23/2026
1.2.0 686 11/14/2025
1.1.2 455 5/15/2025
1.0.1 592 3/25/2025
1.0.0 2,297 1/17/2022