Cogito.Autofac.DependencyInjection
6.1.4
dotnet add package Cogito.Autofac.DependencyInjection --version 6.1.4
NuGet\Install-Package Cogito.Autofac.DependencyInjection -Version 6.1.4
<PackageReference Include="Cogito.Autofac.DependencyInjection" Version="6.1.4" />
<PackageVersion Include="Cogito.Autofac.DependencyInjection" Version="6.1.4" />
<PackageReference Include="Cogito.Autofac.DependencyInjection" />
paket add Cogito.Autofac.DependencyInjection --version 6.1.4
#r "nuget: Cogito.Autofac.DependencyInjection, 6.1.4"
#:package Cogito.Autofac.DependencyInjection@6.1.4
#addin nuget:?package=Cogito.Autofac.DependencyInjection&version=6.1.4
#tool nuget:?package=Cogito.Autofac.DependencyInjection&version=6.1.4
Cogito.Autofac.DependencyInjection
Bridges Autofac and Microsoft.Extensions.DependencyInjection in both
directions, so a container built with Autofac can host services registered the Microsoft way, and
vice versa.
Why
The two containers meet awkwardly. Populate on a root ContainerBuilder is easy to get wrong —
singletons registered through the service collection end up owned by the root scope even when you
wanted them owned by a child. This package gives you a Populate that takes a configuration callback
and an explicit lifetime-scope tag for singletons, plus an AddAutofac for going the other way.
Install
dotnet add package Cogito.Autofac.DependencyInjection
Autofac hosting Microsoft registrations
var builder = new ContainerBuilder();
builder.Populate(services =>
{
services.AddLogging();
services.AddHttpClient();
});
var container = builder.Build();
Pass a lifetimeScopeTagForSingletons when the singletons should belong to a tagged child scope
rather than the root:
builder.Populate(services => services.AddMyThings(), lifetimeScopeTagForSingletons: "request");
Microsoft hosting Autofac registrations
services.AddAutofac(builder => builder.RegisterAllAssemblyModules());
As the host's service provider factory
AutofacServiceProviderFactory plugs into the generic host, which is the usual entry point for a
Cogito application:
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureContainer<ContainerBuilder>(b => b.RegisterAllAssemblyModules())
.Build()
.Run();
License
MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. 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. |
-
.NETFramework 4.7.2
- Autofac (>= 9.3.2)
- Autofac.Extensions.DependencyInjection (>= 11.0.2)
- Cogito.Autofac (>= 6.1.4)
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
-
.NETStandard 2.0
- Autofac (>= 9.3.2)
- Autofac.Extensions.DependencyInjection (>= 11.0.2)
- Cogito.Autofac (>= 6.1.4)
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
-
net6.0
- Autofac (>= 9.3.2)
- Autofac.Extensions.DependencyInjection (>= 11.0.2)
- Cogito.Autofac (>= 6.1.4)
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Cogito.Autofac.DependencyInjection:
| Package | Downloads |
|---|---|
|
Cogito.Extensions.Options.Autofac
Various additions to Microsoft.Extensions.Options for Autofac. |
|
|
Cogito.MassTransit.Autofac
Alternative Autofac integration for MassTransit. |
|
|
Cogito.Extensions.Logging.Serilog.Autofac
Configures the Autofac container to forward Microsoft.Extensions.Logging messages to the Serilog logger. |
|
|
Cogito.AspNetCore.Autofac
Various utilities and extensions for working with Autofac and ASP.Net Core. |
|
|
Cogito.Quartz
Provides utilites and extensions for Quartz. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.1.4 | 63 | 11/28/2026 |
| 6.1.3 | 962 | 9/14/2026 |
| 6.1.2 | 141 | 9/10/2026 |
| 6.1.1 | 885 | 9/10/2026 |
| 6.1.0 | 4,711 | 1/7/2025 |
| 6.0.0 | 8,774 | 12/20/2024 |
| 5.0.5 | 3,116 | 11/29/2023 |
| 5.0.4 | 3,849 | 11/29/2023 |
| 5.0.0 | 1,465 | 11/7/2023 |
| 4.0.18 | 256 | 11/7/2023 |
| 4.0.13 | 8,065 | 9/4/2022 |
| 4.0.11 | 589 | 9/4/2022 |
| 4.0.10 | 700 | 6/6/2022 |
| 4.0.9 | 683 | 6/6/2022 |
| 4.0.7 | 655 | 6/5/2022 |
| 4.0.6 | 638 | 6/5/2022 |
| 4.0.4 | 617 | 6/5/2022 |
| 3.1.10 | 656 | 6/5/2022 |
| 3.1.9 | 3,460 | 10/18/2021 |
| 3.1.7 | 5,579 | 10/10/2021 |