Welcome to Autofac’s documentation!
Autofac is an addictive IoC container for .NET. It manages the dependencies between classes so that applications stay easy to change as they grow in size and complexity. This is achieved by treating regular .NET classes as components.
- Getting Started
- What’s New
- Registering Components
- Resolving Services
- Controlling Scope and Lifetime
- Configuration
- Application Integration
- Best Practices and Recommendations
- Always Resolve Dependencies from Nested Lifetimes
- Structure Configuration with Modules
- Use As<T>() in Delegate Registrations
- Use Constructor Injection
- Use Relationship Types, Not Service Locators
- Register Components from Least-to-Most Specific
- Use Profilers for Performance Checking
- Register Once, Resolve Many
- Register Frequently-Used Components with Lambdas
- Consider a Container as Immutable
- Optimize or Avoid Diagnostics
- Advanced Topics
- Registration Sources
- Adapters and Decorators
- Composites
- Circular Dependencies
- Component Metadata / Attribute Metadata
- Named and Keyed Services
- Delegate Factories
- Owned Instances
- Pooled Instances
- Custom Constructor Selection
- Handling Concurrency
- Multitenant Applications
- AssemblyLoadContext and Lifetime Scopes
- Resolve Pipelines
- Service Pipelines vs Registration Pipelines
- Pipeline Phases
- Adding Registration Middleware
- ResolveRequestContext
- Adding Service Middleware
- Service Middleware Sources
- Aggregate Services
- Type Interceptors
- Cross-Platform and Native Applications
- Debugging and Troubleshooting
- Examples
- Frequently Asked Questions
- How do I work with per-request lifetime scope?
- How do I pick a service implementation by context?
- How do I create a session-based lifetime scope in a web application?
- Why aren’t my assemblies getting scanned after IIS restart?
- How do I conditionally register components?
- How do I share component registrations across application types?
- How do I keep Autofac references isolated away from my app?
- Why are “old versions” of the framework (e.g., System.Core 2.0.5.0) referenced?
- Why don’t all Autofac packages target the latest Autofac core?
- How do I inject configuration, environment, or context parameters?
- How do I pass a parameter to a component in the middle of a resolve chain?
- Why isn’t container registration analysis built in?
- Why are things in my Xamarin app misbehaving?
- Glossary
- Contributor Guide
- Getting Support
- API Documentation
- Owner’s Guide