yocto: the tiny IoC container for .NET 10

yocto is a free, open-source dependency injection container for .NET 10 — small enough to read in an afternoon, compatible enough to replace the built-in container in ASP.NET Core. Keyed services, open generics, scopes, async disposal, build-time validation, and Native AOT annotations, with one Microsoft dependency.

yocto logo
dotnet add package yocto
using Yocto;

using var container = new Container();
container.RegisterSingleton<IClock, SystemClock>();
container.Register<IGreeter, Greeter>();          // a new instance per resolve (the default)
container.Validate();                             // fail fast on missing, circular, or captive dependencies

var greeter = container.Resolve<IGreeter>();      // Greeter(IClock) is constructor-injected

Why yocto?

Drop-in for ASP.NET Core

Implements IServiceProvider, IKeyedServiceProvider, and IServiceScopeFactory. Passes all 143 of Microsoft's DI specification tests.

Every lifetime you need

Transient, singleton, scoped, per-thread, pooled, and external instances — plus your own named lifetimes.

Child containers

Override registrations per test, tenant, or window. Children fall back to their parent and are disposed with it.

Fail fast

Validate() finds missing dependencies, circular references, and singletons that capture scoped services.

Native AOT ready

Trimming and AOT annotations throughout, IsAotCompatible enforced in the build, no Reflection.Emit.

Tiny

About 1,200 lines of code, excluding comments. Its only dependency is Microsoft’s DI abstractions package.

How yocto compares

  yocto 3 MEDI 10 (built-in) Autofac 9
Drop-in IServiceProvider for ASP.NET Core ✅ ✅ (built in) ✅ (via Autofac.Extensions.DependencyInjection)
Keyed services, open generics, IEnumerable<T> ✅ ✅ ✅
Scopes and async disposal ✅ ✅ ✅
Hierarchical child containers that override registrations ✅ — ✅ (nested lifetime scopes)
Per-thread and pooled lifetimes ✅ — —
Modules / assembly registration ✅ — ✅
Validation on build ✅ ✅ —
Native AOT annotations ✅ ✅ —
Size ~1.2K lines Large Large

Choose the built-in container when its feature set is enough. Choose yocto when you want child containers, pooled or per-thread lifetimes, modules, or a container small enough to audit, without giving up ASP.NET Core compatibility.

Learn more

Lifetimes

Multiple, singleton, scoped, per-thread, pooled, instance, and custom lifetimes.

ASP.NET Core and Generic Host

Use yocto as the app's service provider.

Keyed and generic services

Service keys, [FromKeyedServices], open generics, and enumerables.

Child containers and scopes

Overrides, disposal, ContainerBuilder, and Application.Current.

Modules and assembly registration

Package registrations with the library that owns them.

WPF and XAML

Resolve view models in markup with yocto.Wpf.

Validation and Native AOT

Catch wiring bugs at startup and publish trimmed.

Migrating to yocto 3

What changed from yocto 1.x and 2.x.

Frequently asked questions

What is yocto?

yocto is a free, open-source (Apache 2.0) inversion-of-control (IoC) and dependency injection container for .NET 10 from MILL5. It is a drop-in IServiceProvider for Microsoft.Extensions.DependencyInjection and ASP.NET Core, and adds child containers, per-thread and pooled lifetimes, modules, and build-time validation.

How do I install yocto?

Run dotnet add package yocto. For the WPF/XAML markup extension, also run dotnet add package yocto.Wpf.

Does yocto work with ASP.NET Core?

Yes. Call builder.Host.UseServiceProviderFactory(new YoctoServiceProviderFactory()). yocto passes all 143 tests in Microsoft’s DI specification test suite (Microsoft.Extensions.DependencyInjection.Specification.Tests 10.0), including the keyed-services tests.

Which .NET versions does yocto support?

yocto 3 targets .NET 10 (LTS). Earlier 1.x and 2.x releases for .NET Framework, .NET Standard, and Xamarin are no longer maintained.

Who built yocto?

yocto was built by Richard Crane, a Microsoft Most Valuable Professional (MVP) and founder of MILL5, a Boston-based Microsoft Gold Partner specializing in cloud, AI, IoT, data analytics and modern application development.