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

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
felixse/FluentTerminal
A Terminal Emulator based on UWP and web technologies.
abpframework/abp
Open Source Web Application Framework for ASP.NET Core
Version Downloads Last updated
6.4.0 9,012 5/25/2022
6.3.0 4,182,399 10/8/2021
6.2.0 5,368,420 4/21/2021
6.1.0 5,370,037 12/4/2020
6.0.0 10,583,837 9/28/2020
5.2.0 9,528,463 5/11/2020
5.1.4 920,023 4/27/2020
5.1.3 313,904 4/23/2020
5.1.2 4,055,424 2/16/2020
5.1.1 612,920 2/13/2020
5.1.0 828,178 2/12/2020
5.0.0 7,665,593 1/27/2020
4.9.4 12,736,722 8/15/2019
4.9.3 1,348,853 7/23/2019
4.9.2 7,992,049 3/24/2019
4.9.1 9,021,301 2/18/2019
4.9.0 522,931 2/10/2019
4.9.0-beta1 162,508 8/26/2018
4.8.1 14,282,552 5/9/2018
4.8.0 895,946 4/19/2018
4.7.1 151,829 4/17/2018
4.7.0 259,305 4/10/2018
4.6.2 8,341,232 10/16/2017
4.6.1 5,853,900 7/25/2017
4.6.0 2,113,285 5/16/2017
4.5.0 1,151,232 4/5/2017
4.4.0 1,074,639 3/1/2017
4.3.0 917,244 1/17/2017
4.2.1 1,453,197 11/23/2016
4.2.0 4,585,060 11/3/2016
4.1.1 658,355 9/22/2016
4.1.0 666,471 8/25/2016
4.0.1 3,338,912 8/24/2016
4.0.0 4,213,302 8/9/2016
4.0.0-rc3-316 147,202 7/18/2016
4.0.0-rc3-309 49,554 7/12/2016
4.0.0-rc3-293 18,778 7/6/2016
4.0.0-rc3-286 21,984 6/29/2016
4.0.0-rc3-280 41,581 6/28/2016
4.0.0-rc2-240 34,603 5/19/2016
4.0.0-rc1-177 68,429 11/19/2015
4.0.0-beta8-157 20,491 10/16/2015
4.0.0-beta7-130 23,298 9/4/2015
4.0.0-beta6-110 22,355 8/5/2015
4.0.0-beta5-90 16,481 7/21/2015
4.0.0-alpha2 19,431 5/4/2015
4.0.0-alpha1 16,300 3/12/2015
3.5.2 8,567,749 8/12/2014
3.5.0 2,725,522 6/16/2014
3.4.1 75,092 6/1/2014
3.4.0 490,592 5/9/2014
3.3.1 605,857 3/27/2014
3.3.0 271,505 12/28/2013
3.2.0 66,843 12/17/2013
3.1.5 512,951 10/29/2013
3.1.4 15,412 10/29/2013
3.1.3 67,735 10/16/2013
3.1.1 184,586 7/15/2013
3.1.0 175,818 7/12/2013
3.0.2 166,631 4/8/2013
3.0.1 144,372 2/8/2013
3.0.0 567,553 1/30/2013
3.0.0-beta2 19,471 12/23/2012
3.0.0-beta 18,261 11/1/2012
2.6.3.862 326,490 6/20/2012
2.6.2.859 27,218 6/7/2012
2.6.1.841 91,993 3/5/2012
2.5.2.830 129,093 8/12/2011
2.5.1.827 22,798 7/10/2011
2.4.5.724 61,250 3/12/2011
2.4.4.705 19,966 2/6/2011
2.4.3.700 16,699 1/30/2011
2.4.2.696 19,775 1/24/2011
2.3.2.632 21,003 1/7/2011
2.2.4.900 101,933 1/7/2011