Autofac 6.4.0

.NET 5.0 .NET Standard 2.0
Install-Package Autofac -Version 6.4.0
dotnet add package Autofac --version 6.4.0
<PackageReference Include="Autofac" Version="6.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac --version 6.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Autofac, 6.4.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.4.0

// Install Autofac as a Cake Tool
#tool nuget:?package=Autofac&version=6.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.

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
.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
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.5K)

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.

Autofac MVC Integration

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 (261)

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
felixse/FluentTerminal
A Terminal Emulator based on UWP and web technologies.
Version Downloads Last updated
6.4.0 843,317 5/25/2022
6.3.0 6,225,247 10/8/2021
6.2.0 6,383,348 4/21/2021
6.1.0 5,895,204 12/4/2020
6.0.0 12,569,082 9/28/2020
5.2.0 10,396,713 5/11/2020
5.1.4 976,734 4/27/2020
5.1.3 339,728 4/23/2020
5.1.2 4,343,551 2/16/2020
5.1.1 653,271 2/13/2020
5.1.0 901,422 2/12/2020
5.0.0 8,345,462 1/27/2020
4.9.4 13,591,576 8/15/2019
4.9.3 1,398,408 7/23/2019
4.9.2 8,311,636 3/24/2019
4.9.1 9,493,586 2/18/2019
4.9.0 546,564 2/10/2019
4.9.0-beta1 164,222 8/26/2018
4.8.1 14,836,594 5/9/2018
4.8.0 917,246 4/19/2018
4.7.1 159,201 4/17/2018
4.7.0 266,887 4/10/2018
4.6.2 8,651,199 10/16/2017
4.6.1 6,063,651 7/25/2017
4.6.0 2,177,884 5/16/2017
4.5.0 1,181,360 4/5/2017
4.4.0 1,108,542 3/1/2017
4.3.0 955,903 1/17/2017
4.2.1 1,518,307 11/23/2016
4.2.0 4,730,935 11/3/2016
4.1.1 684,715 9/22/2016
4.1.0 688,709 8/25/2016
4.0.1 3,457,567 8/24/2016
4.0.0 4,467,891 8/9/2016
4.0.0-rc3-316 154,826 7/18/2016
4.0.0-rc3-309 49,722 7/12/2016
4.0.0-rc3-293 18,903 7/6/2016
4.0.0-rc3-286 22,202 6/29/2016
4.0.0-rc3-280 41,673 6/28/2016
4.0.0-rc2-240 35,045 5/19/2016
4.0.0-rc1-177 69,609 11/19/2015
4.0.0-beta8-157 20,561 10/16/2015
4.0.0-beta7-130 23,370 9/4/2015
4.0.0-beta6-110 22,421 8/5/2015
4.0.0-beta5-90 16,543 7/21/2015
4.0.0-alpha2 19,490 5/4/2015
4.0.0-alpha1 16,369 3/12/2015
3.5.2 8,876,098 8/12/2014
3.5.0 2,855,656 6/16/2014
3.4.1 75,799 6/1/2014
3.4.0 516,742 5/9/2014
3.3.1 628,036 3/27/2014
3.3.0 280,508 12/28/2013
3.2.0 69,120 12/17/2013
3.1.5 528,489 10/29/2013
3.1.4 15,486 10/29/2013
3.1.3 70,776 10/16/2013
3.1.1 188,307 7/15/2013
3.1.0 186,703 7/12/2013
3.0.2 170,844 4/8/2013
3.0.1 148,936 2/8/2013
3.0.0 595,330 1/30/2013
3.0.0-beta2 19,586 12/23/2012
3.0.0-beta 18,324 11/1/2012
2.6.3.862 342,155 6/20/2012
2.6.2.859 27,818 6/7/2012
2.6.1.841 94,187 3/5/2012
2.5.2.830 133,183 8/12/2011
2.5.1.827 23,239 7/10/2011
2.4.5.724 62,544 3/12/2011
2.4.4.705 20,354 2/6/2011
2.4.3.700 16,896 1/30/2011
2.4.2.696 20,077 1/24/2011
2.3.2.632 21,218 1/7/2011
2.2.4.900 107,948 1/7/2011