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.

Autofac OWIN Integration

GitHub repositories (256)

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

Repository Stars
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
felixse/FluentTerminal
A Terminal Emulator based on UWP and web technologies.
abpframework/abp
Open Source Web Application Framework for ASP.NET Core
jbogard/MediatR
Simple, unambitious mediator implementation in .NET
Version Downloads Last updated
6.4.0 215,008 5/25/2022
6.3.0 4,951,405 10/8/2021
6.2.0 5,745,015 4/21/2021
6.1.0 5,560,475 12/4/2020
6.0.0 11,306,560 9/28/2020
5.2.0 9,851,406 5/11/2020
5.1.4 941,205 4/27/2020
5.1.3 322,410 4/23/2020
5.1.2 4,163,052 2/16/2020
5.1.1 627,093 2/13/2020
5.1.0 857,365 2/12/2020
5.0.0 7,920,736 1/27/2020
4.9.4 13,044,791 8/15/2019
4.9.3 1,366,009 7/23/2019
4.9.2 8,101,426 3/24/2019
4.9.1 9,189,088 2/18/2019
4.9.0 531,205 2/10/2019
4.9.0-beta1 163,114 8/26/2018
4.8.1 14,468,898 5/9/2018
4.8.0 902,505 4/19/2018
4.7.1 154,117 4/17/2018
4.7.0 262,069 4/10/2018
4.6.2 8,447,339 10/16/2017
4.6.1 5,918,630 7/25/2017
4.6.0 2,134,983 5/16/2017
4.5.0 1,161,774 4/5/2017
4.4.0 1,084,994 3/1/2017
4.3.0 929,106 1/17/2017
4.2.1 1,475,367 11/23/2016
4.2.0 4,633,983 11/3/2016
4.1.1 667,079 9/22/2016
4.1.0 672,739 8/25/2016
4.0.1 3,383,482 8/24/2016
4.0.0 4,301,527 8/9/2016
4.0.0-rc3-316 150,368 7/18/2016
4.0.0-rc3-309 49,629 7/12/2016
4.0.0-rc3-293 18,830 7/6/2016
4.0.0-rc3-286 22,040 6/29/2016
4.0.0-rc3-280 41,620 6/28/2016
4.0.0-rc2-240 34,730 5/19/2016
4.0.0-rc1-177 68,830 11/19/2015
4.0.0-beta8-157 20,528 10/16/2015
4.0.0-beta7-130 23,337 9/4/2015
4.0.0-beta6-110 22,392 8/5/2015
4.0.0-beta5-90 16,515 7/21/2015
4.0.0-alpha2 19,462 5/4/2015
4.0.0-alpha1 16,339 3/12/2015
3.5.2 8,668,237 8/12/2014
3.5.0 2,769,733 6/16/2014
3.4.1 75,320 6/1/2014
3.4.0 498,915 5/9/2014
3.3.1 612,756 3/27/2014
3.3.0 274,428 12/28/2013
3.2.0 67,170 12/17/2013
3.1.5 516,709 10/29/2013
3.1.4 15,452 10/29/2013
3.1.3 68,901 10/16/2013
3.1.1 185,845 7/15/2013
3.1.0 178,231 7/12/2013
3.0.2 167,609 4/8/2013
3.0.1 145,626 2/8/2013
3.0.0 577,955 1/30/2013
3.0.0-beta2 19,544 12/23/2012
3.0.0-beta 18,301 11/1/2012
2.6.3.862 330,589 6/20/2012
2.6.2.859 27,324 6/7/2012
2.6.1.841 92,492 3/5/2012
2.5.2.830 130,241 8/12/2011
2.5.1.827 22,924 7/10/2011
2.4.5.724 61,637 3/12/2011
2.4.4.705 20,113 2/6/2011
2.4.3.700 16,756 1/30/2011
2.4.2.696 19,850 1/24/2011
2.3.2.632 21,098 1/7/2011
2.2.4.900 103,262 1/7/2011