Autofac 6.5.0

.NET 5.0 .NET Standard 2.0
dotnet add package Autofac --version 6.5.0
NuGet\Install-Package Autofac -Version 6.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Autofac" Version="6.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac --version 6.5.0
#r "nuget: Autofac, 6.5.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Autofac as a Cake Addin
#addin nuget:?package=Autofac&version=6.5.0

// Install Autofac as a Cake Tool
#tool nuget:?package=Autofac&version=6.5.0

Autofac character Autofac logo

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.

Build status codecov NuGet

Autofac on Stack Overflow Join the chat at https://gitter.im/autofac/autofac

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.

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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2.6K)

Showing the top 5 NuGet packages that depend on Autofac:

Package Downloads
Autofac.Extensions.DependencyInjection The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Autofac implementation of the interfaces in Microsoft.Extensions.DependencyInjection.Abstractions, the .NET Framework dependency injection abstraction.

Autofac.WebApi2 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Autofac integration for ASP.NET WebAPI.

Autofac.Mvc5 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

ASP.NET MVC 5 integration for Autofac.

Autofac.Extras.DynamicProxy The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Autofac extension for enabling AOP in conjunction with Castle.

Autofac.Owin The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

ASP.NET OWIN integration support for Autofac IoC.

GitHub repositories (272)

Showing the top 5 popular GitHub repositories that depend on Autofac:

Repository Stars
dotnet-architecture/eShopOnContainers
Cross-platform .NET sample microservices and container based application that runs on Linux Windows and macOS. Powered by .NET 6, Docker Containers and Azure Kubernetes Services. Supports Visual Studio, VS for Mac and CLI based environments with Docker CLI, dotnet CLI, VS Code or any other code editor.
ardalis/CleanArchitecture
Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core
JamesNK/Newtonsoft.Json
Json.NET is a popular high-performance JSON framework for .NET
abpframework/abp
Open Source Web Application Framework for ASP.NET Core
jbogard/MediatR
Simple, unambitious mediator implementation in .NET
Version Downloads Last updated
6.5.0 665,341 11/16/2022
6.4.0 5,612,242 5/25/2022
6.3.0 10,498,115 10/8/2021
6.2.0 8,431,416 4/21/2021
6.1.0 7,210,401 12/4/2020
6.0.0 17,108,208 9/28/2020
5.2.0 12,442,663 5/11/2020
5.1.4 1,098,255 4/27/2020
5.1.3 385,897 4/23/2020
5.1.2 4,960,892 2/16/2020
5.1.1 723,368 2/13/2020
5.1.0 1,052,665 2/12/2020
5.0.0 9,781,411 1/27/2020
4.9.4 15,627,642 8/15/2019
4.9.3 1,540,762 7/23/2019
4.9.2 9,157,038 3/24/2019
4.9.1 10,558,471 2/18/2019
4.9.0 598,461 2/10/2019
4.9.0-beta1 168,036 8/26/2018
4.8.1 16,473,911 5/9/2018
4.8.0 969,348 4/19/2018
4.7.1 173,919 4/17/2018
4.7.0 286,871 4/10/2018
4.6.2 9,465,844 10/16/2017
4.6.1 6,780,257 7/25/2017
4.6.0 2,333,663 5/16/2017
4.5.0 1,257,901 4/5/2017
4.4.0 1,198,100 3/1/2017
4.3.0 1,041,077 1/17/2017
4.2.1 1,639,653 11/23/2016
4.2.0 5,127,262 11/3/2016
4.1.1 728,997 9/22/2016
4.1.0 735,066 8/25/2016
4.0.1 3,708,708 8/24/2016
4.0.0 5,080,340 8/9/2016
4.0.0-rc3-316 179,471 7/18/2016
4.0.0-rc3-309 50,116 7/12/2016
4.0.0-rc3-293 19,003 7/6/2016
4.0.0-rc3-286 22,368 6/29/2016
4.0.0-rc3-280 41,828 6/28/2016
4.0.0-rc2-240 36,343 5/19/2016
4.0.0-rc1-177 72,787 11/19/2015
4.0.0-beta8-157 20,612 10/16/2015
4.0.0-beta7-130 23,432 9/4/2015
4.0.0-beta6-110 22,489 8/5/2015
4.0.0-beta5-90 16,590 7/21/2015
4.0.0-alpha2 19,535 5/4/2015
4.0.0-alpha1 16,420 3/12/2015
3.5.2 9,646,249 8/12/2014
3.5.0 3,155,517 6/16/2014
3.4.1 77,545 6/1/2014
3.4.0 574,747 5/9/2014
3.3.1 686,030 3/27/2014
3.3.0 318,902 12/28/2013
3.2.0 76,642 12/17/2013
3.1.5 603,678 10/29/2013
3.1.4 15,654 10/29/2013
3.1.3 75,960 10/16/2013
3.1.1 196,484 7/15/2013
3.1.0 227,571 7/12/2013
3.0.2 183,456 4/8/2013
3.0.1 163,112 2/8/2013
3.0.0 672,261 1/30/2013
3.0.0-beta2 19,706 12/23/2012
3.0.0-beta 18,406 11/1/2012
2.6.3.862 378,502 6/20/2012
2.6.2.859 30,132 6/7/2012
2.6.1.841 103,620 3/5/2012
2.5.2.830 148,565 8/12/2011
2.5.1.827 24,740 7/10/2011
2.4.5.724 68,803 3/12/2011
2.4.4.705 21,238 2/6/2011
2.4.3.700 17,796 1/30/2011
2.4.2.696 21,344 1/24/2011
2.3.2.632 21,703 1/7/2011
2.2.4.900 134,457 1/7/2011