Modules and assembly registration

Modules

public sealed class BillingModule : IModule
{
    public void Register(IRegistrar registrar)
    {
        registrar.Register<IInvoiceService, InvoiceService>().AsScoped();
        registrar.RegisterSingleton<ITaxTable, TaxTable>();
    }
}

container.RegisterModule<BillingModule>();

IRegistrar is implemented by both IContainer and ContainerBuilder.

Assembly registration

container.RegisterAssembly(typeof(BillingModule).Assembly);

This applies every public IModule with a parameterless constructor, plus every public static AssemblyRegistration.Initialize(IContainer) method (the yocto 1.x/2.x convention), and returns how many it applied. It uses reflection and is marked RequiresUnreferencedCode; in trimmed or Native AOT apps, call RegisterModule explicitly.

Next: WPF and XAML →

Last reviewed October 13, 2026 · yocto 3.0.0