NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
NuGet · #106 most downloaded on NuGet
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.
Last release 20 days ago
18 Sep 2026
Ships fairly regularly
a new release about every 2 months
Rarely documented
notes for 12 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
16 years old
94 releases · first in 2011
Do not build a held registration's pipeline early by @tillig in #1504 (fixes #1503 ) - a regression introduced in 9.3.3. Registering an open generic f
Do not build a held registration's pipeline early by @tillig in #1504 (fixes #1503) - a regression introduced in 9.3.3. Registering an open generic for several services (.As(typeof(IFirstService<>)).As(typeof(ISecondService<>))) threw InvalidOperationException: Component pipeline has already been built, and cannot be modified. on first resolve whenever anything attached to PipelineBuilding from the component registry's Registered event. Autofac.Extensions.DependencyInjection attaches exactly that way on every registration, so ASP.NET Core applications using a multi-service open generic registration hit it deterministically. The fix restores the ordering 9.3.2 had, where the pipeline is built only after Registered has been raised.
If you are on 9.3.3 and register an open generic against more than one service, upgrade. Thanks to @hjalle for the report and for pinning it to the exact line.
Full Changelog: v9.3.3...v9.3.4
One column per quarter.
Create AnyKey adapter registrations per registry by @tillig in #1498 (fixes #1497 ) - the KeyedService.AnyKey fallback adapter was cached and handed t
KeyedService.AnyKey fallback adapter was cached and handed to every registry that asked for it, so the first scope to receive it built and disposed its pipeline out from under the rest. Other scopes then failed to add middleware, resolved through a disposed activator, or adapted another scope's registration. Multitenant containers hit this most often.System.Diagnostics.DiagnosticSource and Microsoft.Bcl.AsyncInterfaces (netstandard2.0 only) move to 10.0.12.Full Changelog: v9.3.2...v9.3.3
Reduce registration cost incurred by scans for [ServiceKey] attribute by @npease18 ( #1495 , fixes #1480 )
Fix per-resolve closure allocation in resolve pipeline ( #1493 ) by @tillig in #1494
Fix per-resolve closure allocation in resolve pipeline (#1493) by @tillig in #1494
Full Changelog: v9.3.0...v9.3.1
Annotate core for trimming and Native AOT compatibility by @tillig in #1492
Full Changelog: v9.2.0...v9.3.0
Fix decorator parameter selection for derived-service dependencies ( #1459 ) by @tillig in #1484
IStartable throws during Build (#1392) by @tillig in #1485ExternallyOwned ownership for decorators (#1402) by @tillig in #1486Module registry events when hooks are overridden (#1446) by @tillig in #1487GetRegistrationId extension to expose a registration's unique ID (#1327) by @tillig in #1490Full Changelog: v9.1.0...v9.2.0
This is a pretty big release for Autofac with some major new functionality!
This is a pretty big release for Autofac with some major new functionality!
First, Autofac now natively supports the concept of AnyKey. It behaves the same way AnyKey works in Microsoft.Extensions.DependencyInjection, but it is native to Autofac directly. The unit tests here show some very detailed examples of usage, but on a high level:
var builder = new ContainerBuilder();
builder.RegisterType<Service>().Keyed<IService>(KeyedService.AnyKey);
var container = builder.Build();
// Registering as AnyKey allows it to respond to... any key!
var service = container.ResolveKeyed<IService>("service1");The new [ServiceKey] attribute allows you to inject the service key provided during resolution. This is handy in conjunction with AnyKey. Again, this is similar to the construct in Microsoft.Extensions.DependencyInjection, but with native Autofac.
First, mark up your class to take the constructor parameter.
public class Service : IService
{
private readonly string _id;
public Service([ServiceKey] string id) => _id = id;
}Then when you resolve the class, the service key will automatically be injected.
You can also make use of this in a lambda registration.
var builder = new ContainerBuilder();
builder.Register<Service>((ctx, p) => {
var key = p.TryGetKeyedServiceKey(out string value) ? value : null;
return new Service(key);
}).Keyed<Service>(KeyedService.AnyKey);Some metrics have been introduced that can allow you to capture counters on how long middleware is taking, how often lock contention occurs, and so on.
Set the AUTOFAC_METRICS environment variable in your process to true or 1 to enable this feature. You can see the set of counters that will become available here.
⚠️ This is NOT FREE. Collecting counters and metrics will incur a performance hit, so it's not something you want to leave on in production.
A pass over the whole system was made with an eye to trying to claw back some performance. Some additional caching was introduced to help reduce lookups and calculations of reflection data; and a few hot-path optimizations were made for the common situations.
Full Changelog: v9.0.0...v9.1.0
Updated Autofac for .NET 10. New current set of target frameworks: net10.0;net8.0;netstandard2.1;netstandard2.0
Updated Autofac for .NET 10. New current set of target frameworks: net10.0;net8.0;netstandard2.1;netstandard2.0
Dropped support for net6.0, net7.0.
net10.0.Full Changelog: v8.4.0...v9.0.0
Minor breaking change : The shim RequiresUnreferencedCodeAttribute has been changed from public to internal ( #1462 / #1463 - thanks @prochnowc !). Th…
Minor breaking change: The shim RequiresUnreferencedCodeAttribute has been changed from public to internal (#1462/#1463 - thanks @prochnowc!). This will only affect people targeting older/lower .NET standard frameworks who also rely on the shim attribute in Autofac. While it's technically breaking, it didn't seem like a great reason to do a full major release due to the edge case nature of the set of applications/users affected.
Corrected nullable markup on IIndex<K,V>.TryGetValue() since it may return null on failure.
IIndex<K,V>.TryGetValue() since it may return null on failure.Full Changelog: v8.2.1...v8.3.0
Fix #1450 : AutoActivate() no longer hides the default service registration. (Thanks, @nblumhardt !)
Fix #1450: AutoActivate() no longer hides the default service registration. (Thanks, @nblumhardt!)
Fix #1437 : Improve type cache handling for generic type arguments with respect to AssemblyLoadContext disposal ( #1438 - thanks @hemirunner426 !)
AssemblyLoadContext disposal (#1438 - thanks @hemirunner426!)RegisterServiceMiddleware to assist with interceptors/decorators (#1439 - thanks @idiotsky!)Full Changelog: v8.1.1...v8.2.0
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →