Autofac is a .NET inversion-of-control container that wires dependencies between classes so applications stay easier to change as they grow.
Overview
Autofac treats ordinary .NET types as composable components and resolves object graphs from a configured container. You register services with a ContainerBuilder using concrete types, instances, lambdas, or assembly scanning, then build a container and resolve from the root or nested lifetime scopes.
Constructor injection is the primary pattern, with support for property and method injection where needed. Modules let you group registrations in code while XML configuration remains available for deployment-time tweaks. Activation events such as OnActivated and OnActivating hook component startup and teardown without sprawling glue code.
Packages on NuGet cover the core container plus application integration and extended capability add-ons. Documentation, API references, and getting-started material walk through integrating Autofac into an application, and a ecosystem of integration libraries targets popular .NET frameworks.
Autofac is maintained as open source under the MIT license and is intended for use in commercial and community applications that want explicit control over dependency lifetimes and registration composition.
Key features
- ContainerBuilder component registration
- Lifetime scopes and nested scopes
- Constructor, property, and method injection
- Autofac modules for grouped setup
- Assembly scanning registrations
- XML configuration support
- Component activation events
- Framework integration packages
Use cases
- Structuring large .NET application dependencies
- Swapping implementations per environment
- Scoped services in web and worker apps
- Modular registration across feature areas
- Testable composition roots