Autofac 6.5.0

There is a newer version of this package available.
See the version list below for details.
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 and Polyglot Notebooks. 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 Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 was computed.  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 was computed.  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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2.9K)

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 cross-platform document processing library that allows developers to work with a variety of Microsoft Word, OpenOffice, Web, PDF, and image file formats. .NET developers can easily create, open, read, render, edit, convert, merge, split, compare documents. Almost all mainstream document formats are supported, including DOCX, DOC, RTF, ODT, PDF, Markdown, HTML, XML, XAML, MOBI, PNG, JPG. We also provide powerful features to generate reports from document templates and data sources.

Autofac.Extras.DynamicProxy

Autofac extension for enabling AOP in conjunction with Castle.

Autofac.Mvc5

ASP.NET MVC 5 integration for Autofac.

GitHub repositories (297)

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
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
jbogard/MediatR
Simple, unambitious mediator implementation in .NET
kgrzybek/modular-monolith-with-ddd
Full Modular Monolith application with Domain-Driven Design approach.
Version Downloads Last updated
8.1.1 508,775 10/9/2024
8.1.0 1,130,194 9/2/2024
8.0.0 10,728,248 1/16/2024
7.1.0 6,597,367 8/11/2023
7.0.1 4,572,974 4/18/2023
7.0.0 3,195,239 3/7/2023
6.5.0 10,107,349 11/16/2022
6.4.0 26,890,114 5/25/2022
6.3.0 20,788,924 10/8/2021
6.2.0 13,777,787 4/21/2021
6.1.0 10,581,872 12/4/2020
6.0.0 31,365,323 9/28/2020
5.2.0 19,134,845 5/11/2020
5.1.4 1,482,987 4/27/2020
5.1.3 513,284 4/23/2020
5.1.2 6,595,152 2/16/2020
5.1.1 942,301 2/13/2020
5.1.0 1,459,973 2/12/2020
5.0.0 14,214,922 1/27/2020
4.9.4 22,616,187 8/15/2019
4.9.3 1,970,867 7/23/2019
4.9.2 11,660,016 3/24/2019
4.9.1 15,577,820 2/18/2019
4.9.0 801,079 2/10/2019
4.9.0-beta1 177,048 8/26/2018
4.8.1 22,880,654 5/9/2018
4.8.0 1,274,786 4/19/2018
4.7.1 246,554 4/17/2018
4.7.0 397,800 4/10/2018
4.6.2 12,453,505 10/16/2017
4.6.1 9,001,552 7/25/2017
4.6.0 2,954,745 5/16/2017
4.5.0 1,739,942 4/5/2017
4.4.0 1,607,032 3/1/2017
4.3.0 1,391,257 1/17/2017
4.2.1 2,062,000 11/23/2016
4.2.0 6,469,367 11/3/2016
4.1.1 967,548 9/22/2016
4.1.0 867,664 8/25/2016
4.0.1 4,642,780 8/24/2016
4.0.0 7,190,089 8/9/2016
4.0.0-rc3-316 252,643 7/18/2016
4.0.0-rc3-309 53,737 7/12/2016
4.0.0-rc3-293 20,619 7/6/2016
4.0.0-rc3-286 25,214 6/29/2016
4.0.0-rc3-280 44,788 6/28/2016
4.0.0-rc2-240 42,356 5/19/2016
4.0.0-rc1-177 79,113 11/19/2015
4.0.0-beta8-157 21,740 10/16/2015
4.0.0-beta7-130 24,600 9/4/2015
4.0.0-beta6-110 23,661 8/5/2015
4.0.0-beta5-90 17,684 7/21/2015
4.0.0-alpha2 20,661 5/4/2015
4.0.0-alpha1 17,557 3/12/2015
3.5.2 12,214,008 8/12/2014
3.5.0 4,647,449 6/16/2014
3.4.1 85,403 6/1/2014
3.4.0 762,787 5/9/2014
3.3.1 882,056 3/27/2014
3.3.0 423,193 12/28/2013
3.2.0 100,240 12/17/2013
3.1.5 835,401 10/29/2013
3.1.4 16,922 10/29/2013
3.1.3 117,199 10/16/2013
3.1.1 223,397 7/15/2013
3.1.0 386,021 7/12/2013
3.0.2 221,375 4/8/2013
3.0.1 247,886 2/8/2013
3.0.0 912,647 1/30/2013
3.0.0-beta2 21,671 12/23/2012
3.0.0-beta 21,096 11/1/2012
2.6.3.862 567,305 6/20/2012
2.6.2.859 34,328 6/7/2012
2.6.1.841 242,573 3/5/2012
2.5.2.830 181,424 8/12/2011
2.5.1.827 27,944 7/10/2011
2.4.5.724 91,288 3/12/2011
2.4.4.705 24,806 2/6/2011
2.4.3.700 20,123 1/30/2011
2.4.2.696 23,962 1/24/2011
2.3.2.632 24,073 1/7/2011
2.2.4.900 238,268 1/7/2011