Autofac 8.2.1
dotnet add package Autofac --version 8.2.1
NuGet\Install-Package Autofac -Version 8.2.1
<PackageReference Include="Autofac" Version="8.2.1" />
<PackageVersion Include="Autofac" Version="8.2.1" />
<PackageReference Include="Autofac" />
paket add Autofac --version 8.2.1
#r "nuget: Autofac, 8.2.1"
#addin nuget:?package=Autofac&version=8.2.1
#tool nuget:?package=Autofac&version=8.2.1
Autofac is an IoC container for Microsoft .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.
Get Packages
You can get Autofac by grabbing the latest NuGet package. There are several application integration and extended functionality packages to choose from. If you're feeling adventurous, continuous integration builds are on MyGet.
Release notes are available on GitHub.
Get Help
Need help with Autofac? We have a documentation site as well as API documentation. We're ready to answer your questions on Stack Overflow or check out the discussion forum.
Get Started
Our Getting Started tutorial walks you through integrating Autofac with a simple application and gives you some starting points for learning more.
Super-duper quick start:
Register components with a ContainerBuilder
and then build the component container.
var builder = new ContainerBuilder();
builder.Register(c => new TaskController(c.Resolve<ITaskRepository>()));
builder.RegisterType<TaskController>();
builder.RegisterInstance(new TaskController());
builder.RegisterAssemblyTypes(controllerAssembly);
var container = builder.Build();
Resolve services from a lifetime scope - either the container or a nested scope:
var taskController = container.Resolve<TaskController>();
There is a growing number of application integration libraries that make using Autofac with your application a snap. Support for several popular frameworks is also available through the "Extras" packages.
Intrigued? Check out our Getting Started walkthrough!
Project
Autofac is licensed under the MIT license, so you can comfortably use it in commercial applications (we still love contributions though).
File issues in the repo with the associated feature/code.
- Autofac - Core dependency resolution and common functions (this repo).
- Autofac.AspNetCore.Multitenant - Multitenant DI support for ASP.NET Core applications.
- Autofac.Configuration - JSON/XML file-based configuration support.
- Autofac.Diagnostics.DotGraph - Diagnostics support to enable DOT graph visualization of resolve requests.
- Autofac.Extensions.DependencyInjection - .NET Core integration for Autofac.
- Autofac.Extras.AggregateService - Dynamic aggregate service implementation generation.
- Autofac.Extras.AttributeMetadata - Metadata scanning/filtering through attributes.
- Autofac.Extras.CommonServiceLocator - Common Service Locator implementation backed by Autofac.
- Autofac.Extras.DynamicProxy - Decorators and interceptors.
- Autofac.Extras.FakeItEasy - FakeItEasy mocking framework integration.
- Autofac.Extras.Moq - Moq mocking framework integration.
- Autofac.Mef - MEF catalog integration.
- Autofac.Multitenant - Multitenant dependency resolution support.
- Autofac.Multitenant.Wcf - Multitenant WCF service hosting.
- Autofac.Mvc - ASP.NET MVC integration.
- Autofac.Mvc.Owin - OWIN support for ASP.NET MVC.
- Autofac.Owin - Core OWIN support - shared middleware for request lifetime integration.
- Autofac.Pooling - Support for pooled instance lifetime scopes.
- Autofac.ServiceFabric - Application integration for Service Fabric services.
- Autofac.SignalR - Application integration for SignalR.
- Autofac.Wcf - WCF service hosting.
- Autofac.Web - ASP.NET web forms integration.
- Autofac.WebApi - Application integration for Web API.
- Autofac.WebApi.Owin - OWIN support for Web API.
Sponsors
Autofac is supported by AWS. Thanks for your contribution!
Contributing / Pull Requests
Refer to the Contributor Guide for setting up and building Autofac source.
You can also open this repository right now in VS Code.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
-
.NETStandard 2.1
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
-
net6.0
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
-
net7.0
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
-
net8.0
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
NuGet packages (3.0K)
Showing the top 5 NuGet packages that depend on Autofac:
Package | Downloads |
---|---|
Autofac.Extensions.DependencyInjection
Autofac implementation of the interfaces in Microsoft.Extensions.DependencyInjection.Abstractions, the .NET Framework dependency injection abstraction. |
|
Autofac.WebApi2
Autofac integration for ASP.NET WebAPI. |
|
Aspose.Words
Aspose.Words for .NET is a powerful, high-performance document processing library for creating, editing, converting, and rendering Word and PDF files in C#. It supports DOCX, DOC, RTF, ODT, HTML, PDF, Markdown, and over 30 formats. Designed for .NET developers, it enables advanced document automation, mail merge, text extraction, and report generation. Aspose.Words ensures high fidelity in document conversion, seamless API integration, and cross-platform compatibility. Ideal for cloud, web, and desktop applications. |
|
Autofac.Extras.DynamicProxy
Autofac extension for enabling AOP in conjunction with Castle. |
|
Autofac.Mvc5
ASP.NET MVC 5 integration for Autofac. |
GitHub repositories (296)
Showing the top 20 popular GitHub repositories that depend on Autofac:
Repository | Stars |
---|---|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
Jackett/Jackett
API Support for your favorite torrent trackers
|
|
kgrzybek/modular-monolith-with-ddd
Full Modular Monolith application with Domain-Driven Design approach.
|
|
jbogard/MediatR
Simple, unambitious mediator implementation in .NET
|
|
JamesNK/Newtonsoft.Json
Json.NET is a popular high-performance JSON framework for .NET
|
|
felixse/FluentTerminal
A Terminal Emulator based on UWP and web technologies.
|
|
dotnet/yarp
A toolkit for developing high-performance HTTP reverse proxy applications.
|
|
Richasy/Bili.Uwp
适用于新系统UI的哔哩
|
|
BartoszCichecki/LenovoLegionToolkit
Lightweight Lenovo Vantage and Hotkeys replacement for Lenovo Legion laptops.
|
|
ServiceStack/ServiceStack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
|
|
win-acme/win-acme
A simple ACME client for Windows (for use with Let's Encrypt et al.)
|
|
xamarin/xamarin-forms-samples
Sample apps built using the Xamarin.Forms framework
|
|
cq-panda/Vue.NetCore
(已支持sqlsugar).NetCore、.Net6、Vue2、Vue3、Vite、TypeScript、Element plus+uniapp前后端分离,全自动生成代码;支持移动端(ios/android/h5/微信小程序。http://www.volcore.xyz/
|
|
cake-build/cake
:cake: Cake (C# Make) is a cross platform build automation system.
|
|
fluentmigrator/fluentmigrator
Fluent migrations framework for .NET
|
|
fanliang11/surging
Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming ,The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service governance to ensure reliable RPC communication, the engine contains Diagnostic, link tracking for protocol and middleware calls, and integration SkyWalking Distributed APM
|
|
cyanfish/naps2
Scan documents to PDF and more, as simply as possible.
|
|
ChangemakerStudios/Papercut-SMTP
Papercut SMTP -- The Simple Desktop Email Server
|
|
bombomby/optick
C++ Profiler For Games
|
|
kgrzybek/sample-dotnet-core-cqrs-api
Sample .NET Core REST API CQRS implementation with raw SQL and DDD using Clean Architecture.
|
Version | Downloads | Last updated |
---|---|---|
8.2.1 | 23,762 | 4/3/2025 |
8.2.0 | 1,856,109 | 12/17/2024 |
8.1.1 | 3,184,071 | 10/9/2024 |
8.1.0 | 4,375,745 | 9/2/2024 |
8.0.0 | 17,146,541 | 1/16/2024 |
7.1.0 | 8,003,929 | 8/11/2023 |
7.0.1 | 5,121,945 | 4/18/2023 |
7.0.0 | 3,536,351 | 3/7/2023 |
6.5.0 | 12,345,907 | 11/16/2022 |
6.4.0 | 30,246,193 | 5/25/2022 |
6.3.0 | 22,456,237 | 10/8/2021 |
6.2.0 | 14,872,812 | 4/21/2021 |
6.1.0 | 11,002,797 | 12/4/2020 |
6.0.0 | 33,575,268 | 9/28/2020 |
5.2.0 | 20,708,114 | 5/11/2020 |
5.1.4 | 1,545,758 | 4/27/2020 |
5.1.3 | 545,925 | 4/23/2020 |
5.1.2 | 6,860,639 | 2/16/2020 |
5.1.1 | 986,116 | 2/13/2020 |
5.1.0 | 1,527,912 | 2/12/2020 |
5.0.0 | 15,149,730 | 1/27/2020 |
4.9.4 | 23,909,438 | 8/15/2019 |
4.9.3 | 2,051,670 | 7/23/2019 |
4.9.2 | 11,982,209 | 3/24/2019 |
4.9.1 | 17,942,944 | 2/18/2019 |
4.9.0 | 829,235 | 2/10/2019 |
4.9.0-beta1 | 179,966 | 8/26/2018 |
4.8.1 | 24,371,145 | 5/9/2018 |
4.8.0 | 1,327,876 | 4/19/2018 |
4.7.1 | 259,187 | 4/17/2018 |
4.7.0 | 411,003 | 4/10/2018 |
4.6.2 | 12,977,907 | 10/16/2017 |
4.6.1 | 9,452,342 | 7/25/2017 |
4.6.0 | 3,066,024 | 5/16/2017 |
4.5.0 | 1,999,448 | 4/5/2017 |
4.4.0 | 1,685,526 | 3/1/2017 |
4.3.0 | 1,434,920 | 1/17/2017 |
4.2.1 | 2,140,824 | 11/23/2016 |
4.2.0 | 6,746,046 | 11/3/2016 |
4.1.1 | 994,605 | 9/22/2016 |
4.1.0 | 896,746 | 8/25/2016 |
4.0.1 | 4,846,784 | 8/24/2016 |
4.0.0 | 7,625,531 | 8/9/2016 |
4.0.0-rc3-316 | 269,000 | 7/18/2016 |
4.0.0-rc3-309 | 54,433 | 7/12/2016 |
4.0.0-rc3-293 | 20,977 | 7/6/2016 |
4.0.0-rc3-286 | 25,360 | 6/29/2016 |
4.0.0-rc3-280 | 44,967 | 6/28/2016 |
4.0.0-rc2-240 | 43,296 | 5/19/2016 |
4.0.0-rc1-177 | 81,090 | 11/19/2015 |
4.0.0-beta8-157 | 21,882 | 10/16/2015 |
4.0.0-beta7-130 | 24,771 | 9/4/2015 |
4.0.0-beta6-110 | 23,797 | 8/5/2015 |
4.0.0-beta5-90 | 17,841 | 7/21/2015 |
4.0.0-alpha2 | 20,803 | 5/4/2015 |
4.0.0-alpha1 | 17,697 | 3/12/2015 |
3.5.2 | 12,638,978 | 8/12/2014 |
3.5.0 | 4,941,410 | 6/16/2014 |
3.4.1 | 88,156 | 6/1/2014 |
3.4.0 | 801,341 | 5/9/2014 |
3.3.1 | 946,957 | 3/27/2014 |
3.3.0 | 429,240 | 12/28/2013 |
3.2.0 | 104,533 | 12/17/2013 |
3.1.5 | 842,451 | 10/29/2013 |
3.1.4 | 17,116 | 10/29/2013 |
3.1.3 | 132,566 | 10/16/2013 |
3.1.1 | 229,548 | 7/15/2013 |
3.1.0 | 408,702 | 7/12/2013 |
3.0.2 | 228,337 | 4/8/2013 |
3.0.1 | 252,611 | 2/8/2013 |
3.0.0 | 962,796 | 1/30/2013 |
3.0.0-beta2 | 21,823 | 12/23/2012 |
3.0.0-beta | 21,451 | 11/1/2012 |
2.6.3.862 | 585,898 | 6/20/2012 |
2.6.2.859 | 35,027 | 6/7/2012 |
2.6.1.841 | 244,901 | 3/5/2012 |
2.5.2.830 | 186,312 | 8/12/2011 |
2.5.1.827 | 28,249 | 7/10/2011 |
2.4.5.724 | 92,542 | 3/12/2011 |
2.4.4.705 | 25,168 | 2/6/2011 |
2.4.3.700 | 20,305 | 1/30/2011 |
2.4.2.696 | 24,276 | 1/24/2011 |
2.3.2.632 | 24,315 | 1/7/2011 |
2.2.4.900 | 262,642 | 1/7/2011 |
Release notes are at https://github.com/autofac/Autofac/releases