![]() |
VOOZH | about |
dotnet add package Autofac.Extensions.DependencyInjection --version 11.0.1
NuGet\Install-Package Autofac.Extensions.DependencyInjection -Version 11.0.1
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="11.0.1" />
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="11.0.1" />Directory.Packages.props
<PackageReference Include="Autofac.Extensions.DependencyInjection" />Project file
paket add Autofac.Extensions.DependencyInjection --version 11.0.1
#r "nuget: Autofac.Extensions.DependencyInjection, 11.0.1"
#:package Autofac.Extensions.DependencyInjection@11.0.1
#addin nuget:?package=Autofac.Extensions.DependencyInjection&version=11.0.1Install as a Cake Addin
#tool nuget:?package=Autofac.Extensions.DependencyInjection&version=11.0.1Install as a Cake Tool
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
Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.
This quick start shows how to use the IServiceProviderFactory{T} integration that ASP.NET Core supports to help automatically build the root service provider for you. If you want more manual control, check out the documentation for examples.
Autofac.Extensions.DependencyInjection package from NuGet.Program.Main method, where you configure the HostBuilder, call UseAutofac to hook Autofac into the startup pipeline.ConfigureServices method of your Startup class register things into the IServiceCollection using extension methods provided by other libraries.ConfigureContainer method of your Startup class register things directly into an Autofac ContainerBuilder.The IServiceProvider will automatically be created for you, so there's nothing you have to do but register things.
public class Program
{
public static async Task Main(string[] args)
{
// The service provider factory used here allows for
// ConfigureContainer to be supported in Startup with
// a strongly-typed ContainerBuilder.
var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webHostBuilder => {
webHostBuilder
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
})
.Build();
await host.RunAsync();
}
}
public class Startup
{
public Startup(IWebHostEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
this.Configuration = builder.Build();
}
public IConfiguration Configuration { get; private set; }
// ConfigureServices is where you register dependencies. This gets
// called by the runtime before the ConfigureContainer method, below.
public void ConfigureServices(IServiceCollection services)
{
// Add services to the collection. Don't build or return
// any IServiceProvider or the ConfigureContainer method
// won't get called.
services.AddOptions();
}
// ConfigureContainer is where you can register things directly
// with Autofac. This runs after ConfigureServices so the things
// here will override registrations made in ConfigureServices.
// Don't build the container; that gets done for you. If you
// need a reference to the container, you need to use the
// "Without ConfigureContainer" mechanism shown later.
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterModule(new AutofacModule());
}
// Configure is where you add middleware. This is called after
// ConfigureContainer. You can use IApplicationBuilder.ApplicationServices
// here if you need to resolve things from the container.
public void Configure(
IApplicationBuilder app,
ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMvc();
}
}
Our ASP.NET Core integration documentation contains more information about using Autofac with ASP.NET Core.
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.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Autofac.Extensions.DependencyInjection:
| Package | Downloads |
|---|---|
|
DH.Core
DH框架基类核心库 |
|
|
Volo.Abp.Autofac
Package Description |
|
|
Autofac.AspNetCore.Multitenant
Multitenant Autofac container integration support for ASP.NET Core. |
|
|
TIKSN-Framework
TIKSN Framework is a .NET 10 application framework and utility library for building modular services, command-line tools, data-driven applications, and .NET MAUI apps. It includes dependency injection helpers, Autofac modules, repository, query repository, file repository, stream repository, pagination, unit-of-work abstractions, Entity Framework Core, Azure Table Storage, Azure Blob Storage, MongoDB, LiteDB, and RavenDB adapters, memory, distributed, and hybrid repository cache decorators, finance and money types, pricing models, currency conversion, central-bank foreign exchange providers, globalization, language and region localization resources, JSON, XML, MessagePack, custom binary serialization, Protocol Buffers-backed licensing schema support, license generation and signature services, shell and PowerShell application infrastructure, telemetry abstractions, correlation IDs, settings, known folders, network connectivity, antimalware abstractions, versioning, numbering, time period types, REST helpers, sitemap models, and platform-specific MAUI registrations. |
|
|
Lykke.Common
Lykke common tools and utilities |
Showing the top 20 popular GitHub repositories that depend on Autofac.Extensions.DependencyInjection:
| Repository | Stars |
|---|---|
|
dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
|
|
|
Jackett/Jackett
API Support for your favorite torrent trackers
|
|
|
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.
|
|
|
kgrzybek/modular-monolith-with-ddd
Full Modular Monolith application with Domain-Driven Design approach.
|
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
LuckyPennySoftware/MediatR
Simple, unambitious mediator implementation in .NET
|
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
|
nopSolutions/nopCommerce
ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
|
|
|
danielgerlag/workflow-core
Lightweight workflow engine for .NET Standard
|
|
|
domaindrivendev/Swashbuckle.AspNetCore
Swagger tools for documenting API's built on ASP.NET Core
|
|
|
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
|
|
|
openiddict/openiddict-core
Flexible and versatile OAuth 2.0/OpenID Connect stack for .NET
|
|
|
cq-panda/Vue.NetCore
(已支持sqlsugar).NetCore、.Net6、Vue2、Vue3、Vite、TypeScript、Element plus+uniapp前后端分离,全自动生成代码;支持移动端(ios/android/h5/微信小程序。http://www.volcore.xyz/
|
|
|
kerryjiang/SuperSocket
SuperSocket is a high-performance, extensible socket server application framework for .NET. It provides a robust architecture for building custom network communication applications with support for multiple protocols including TCP, UDP, and WebSocket.
|
|
|
martinothamar/Mediator
A high performance implementation of Mediator pattern in .NET using source generators.
|
|
|
fluentmigrator/fluentmigrator
Fluent migrations framework for .NET
|
|
|
ChangemakerStudios/Papercut-SMTP
Papercut SMTP -- The Simple Desktop Email Server
|
|
|
microsurging/surging
Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming.
|
|
|
kgrzybek/sample-dotnet-core-cqrs-api
Sample .NET Core REST API CQRS implementation with raw SQL and DDD using Clean Architecture.
|
|
|
ashmind/SharpLab
.NET language playground
|
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.1 | 0 | 6/17/2026 |
| 11.0.0 | 3,245,577 | 3/31/2026 |
| 10.0.0 | 29,815,792 | 9/2/2024 |
| 9.0.0 | 27,002,394 | 1/16/2024 |
| 8.0.0 | 39,516,423 | 5/25/2022 |
| 7.2.0 | 22,559,771 | 11/9/2021 |
| 7.2.0-preview.1 | 149,715 | 7/15/2021 |
| 7.1.0 | 25,512,458 | 10/29/2020 |
| 7.0.2 | 1,573,302 | 10/6/2020 |
| 7.0.1 | 428,999 | 9/28/2020 |
| 7.0.0 | 293,197 | 9/28/2020 |
| 6.0.0 | 25,594,258 | 1/27/2020 |
| 5.0.1 | 10,246,084 | 10/7/2019 |
| 5.0.0 | 2,324,308 | 9/23/2019 |
| 5.0.0-rc2 | 28,658 | 9/19/2019 |
| 5.0.0-rc1 | 26,524 | 8/29/2019 |
| 4.4.0 | 12,900,978 | 2/25/2019 |
| 4.3.1 | 6,083,292 | 11/6/2018 |
| 4.3.0 | 3,770,174 | 8/16/2018 |
| 4.2.2 | 6,005,057 | 3/20/2018 |
Release notes are at https://github.com/autofac/Autofac.Extensions.DependencyInjection/releases