The Ultimate List of .NET Dependency Injection Frameworks

The Ultimate List of .NET Dependency Injection Frameworks


Dependency Injection. Some love it, some hate it. For some developers it might be an anti-pattern, unnecessary, other developers cannot think about building applications without it.

I believe that there are use cases where Dependency Injection frameworks are a good choice. Therefore, I created a few videos about Dependency Injection on my YouTube channel. Anyway, Dependency Injection frameworks are still around in 2019.

There is no overview about the current state of Dependency Injection frameworks available on the internet. Therefore, I decided to create a list as a reference.

The goal of this overview is to provide facts and help you narrow down on the options for your project. It’s not meant to be a guide on which framework to choose or to give opinionated recommendations.

The following list contains all available Dependency Injection frameworks for the .NET platform in alphabetical order beginning with the actively maintained and developed frameworks ending with the inactive and deprecated frameworks.

Diagram: Comparison of avg. daily downloads per framework

Table of contents

Autofac

Autofac Logo

Autofac is an addictive Inversion of Control container for .NET Core, ASP.NET Core, .NET 4.5.1+, Universal Windows apps, and more. Its core features are the modularity system and the fluent API for dependency registrations.

As it was written when the .NET Framework 3.5 was released, it was the first Dependency Injection framework to support lamda registrations. According to the original creator Nicholas Blumhardt the inspiration for this feature came from Needle which is a IoC container for Ruby.

Websitehttps://www.autofac.org/
Platforms.NET Framework 4.5, .NET Core, Silverlight 5, Universal Windows Platform Apps (UWP), Windows Phone 8
GitHub2300+ Stars, 550+ Forks
First released2007
NuGet19M+ total downloads, 6.5K+ downloads per day (avg)
Additional FeaturesInterceptors, Concurrency Handling, Multitenant support, various (test) framework integrations
DocumentationDocumentation
Developmentactive

Hint: If you want to get into Dependency Injection using Autofac, check out my YouTube channel where I show the basics of Dependency Injection using Autofac.

Castle Windsor

Castle Windsor logo

According to their project website, “Castle Windsor is a best of breed, mature Inversion of Control container available for .NET.”

Websitehttp://www.castleproject.org/projects/windsor/
Platforms.NET Framework 4.5, .NET Standard 1.6 (with a bunch of missing features, see project page for more details)
GitHub900+ Stars, 350+ Forks
First released2004
NuGet4.4M+ total downloads, 1.5K downloads per day (avg)
Additional FeaturesAspect-oriented programming (AOP), Proxies, and Interceptors (using Castle.DynamicProxy)
DocumentationDocumentation
Developmentactive

According to Jonathon Rossi, one of the active maintainers, they plan to add .NET Standard 2.1 support soon since Reflection.Emit has been restored to .NET Standard which is needed for DynamicProxy related features. Some of the unnecessary legacy features will not be supported.

Lamar

Lamar is the new kid on the block. Its initial commit date is March 2018 according to the GitHub repository. The idea behind Lamar is to create a successor to StructureMap. According to the project website, its focus is the performance.

Because Lamar supports most of StructureMap’s IContainer syntax, Lamar is an interesting opportunity if a project is currently using StructureMap and should be moved to a more modern, faster framework. As it’s one of the newest frameworks it’s also worth considering to be used in new projects.

Lamar provides integration to the ASP.NET core Dependency Injection mechanism.

Websitehttps://jasperfx.github.io/lamar/
Platforms.NET Framework 4.6+, .NET Standard 2.0
GitHub140+ Stars, 20+ Forks
First released2018
NuGet25K+ total downloads, 75+ downloads per day (avg)
Additional FeaturesInterceptors using Decorators, Diagnostics
DocumentationDocumentation
Developmentactive

LightInject

LightInject logo

LightInject proclaims to be an ultra-lightweight IoC container for the .NET platform. This does not mean that the feature set is limited. LightInject provides different lifetime scopes, explicit and implicit service registration, as well as lazy dependency resolution.

It comes with many framework integrations and makes use of modern .NET platform features to provide a good developer experience. LightInject also provides clean and understandable documentation featuring code examples and therefore makes it easy to get started.

Websitehttps://www.lightinject.net/
Platforms.NET Framework 4.5.2+, .NET Standard 1.1
GitHub340+ Stars, 100+ Forks
First released2011
NuGet650K+ total downloads, 240+ downloads per day (avg)
Additional FeaturesIntegrations with SignalR, Nancy, ASP.NET core, xUnit
DocumentationDocumentation
Developmentactive

Ninject

Ninject Logo

Ninject is one of the well-known .NET Dependency Injection frameworks. Ninject claims to make your software much easier to change after its initial release because Ninject is focused on simplicity and ease of use.

Ninject has a big community which developed many extensions to the core Ninject project including MVC support, WCF support and many more.

Websitehttp://www.ninject.org
Platforms.NET Framework 3.0+, Silverlight, Windows Phone 7, Mono, .NET Standard 2.0
GitHub2100+ Stars, 500+ Forks
First released2008
NuGet8.4M+ total downloads, 2.8K+ downloads per day (avg)
Additional FeaturesMVC support, WCF support, interceptors, conventions, named scopes, Logging, message brokers, Quarz, and many more.
DocumentationDocumentation
Developmentactive

SimpleInjector

SimpleInjector logo

Simple Injector is an easy-to-use Dependency Injection (DI) library. Simple Injector not only wants to be simple to use but is also optimized for performance and concurrent use. Its the goal of the project to be an alternative for developers who want to focus on the important stuff while SimpleInjector is doing its job.

Websitehttps://simpleinjector.org
Platforms.NET Framework 4.0+, .NET Standard Mono, Silverlight, Windows Phone, UWP
GitHub700+ Stars, 100+ Forks
First released2010
NuGet4.3M+ total downloads, 1.6K+ downloads per day (avg)
Additional Features(web) framework integrations, Wcf integration
DocumentationDocumentation
Developmentactive

Spring.NET

Spring.NET logo

According to their project website, “Spring.NET provides comprehensive infrastructural support for developing enterprise .NET applications. (…) The design of Spring.NET is based on the Java version of the Spring Framework.”

Sprint.NET contains various NuGet packages with additional features beyond dependency injection such as aspect-oriented programming, ADO.NET and NHibernate adapters, test integrations and much more.

Websitehttp://springframework.net/
Platforms.NET Framework 4.5.2, .NET Standard 2.0
GitHub500+ Stars, 250+ Forks
First released2005
NuGet310K+ total downloads, 110+ downloads per day (avg)
Additional Featuresaspect-oriented programming AOP, data adapters (ADO.Net, NHibernate), Web extensions, NUnit, MsTest, Messaging, Quartz, Velocity.
DocumentationDocumentation
Developmentactive

Unity

Unity logo

The Unity Container (Unity) is a lightweight, extensible dependency injection container. It facilitates building loosely coupled applications and provides various advantages for developers. It supports registration by convention and type interception.

Unity was created and developed by Microsoft and handed off to the community in 2015.

Websitehttps://unitycontainer.github.io/
Platforms.NET Framework 4.0+, .NET Core, .NET Standard 1.0 and 2.0
GitHub1000+ Stars, 250+ Forks
First released2008
NuGet14.9M+ total downloads, 5.1K+ downloads per day (avg)
Additional Featurestype interception, framework integrations
DocumentationDocumentation
Developmentactive

LinFu

LinFu (“Language INdependent Features Underneath [.NET].”) is a small project founded by Philip Laureano in 2007. It is a framework that adds mixins, inversion of control and other language features to the Common Language Runtime (CLR).

Websitehttps://github.com/philiplaureano/LinFu
Platforms.NET Framework 2.0+
GitHub180+ Stars, 30+ Forks
First released2007
NuGet310K+ total downloads, 110+ downloads per day (avg)
Additional FeaturesMixins
DocumentationDocumentation
Developmentinactive

Managed Extensibility Framework (MEF)

The following description is taken from the official .NET framework documentation article about MEF provided by Microsoft:

“The Managed Extensibility Framework or MEF is a library for creating lightweight, extensible applications. It allows application developers to discover and use extensions with no configuration required. It also lets extension developers easily encapsulate code and avoid fragile hard dependencies. MEF not only allows extensions to be reused within applications but across applications as well.”

Websitehttps://github.com/MicrosoftArchive/mef
Platforms.NET Framework 4.0+
GitHub60+ Stars, 20+ Forks
First released2010
NuGetnot available
DocumentationDocumentation
Developmentdeprecated

PicoContainer.NET

Pico Container.NET is a lightweight dependency injection framework providing only the necessary features, no overhead. The project is no longer continued.

Websitehttp://picocontainer.com/
Platforms.NET Framework
GitHub90+ Stars, 20+ Forks
First released2004
NuGetnot available
DocumentationDocumentation
Developmentabandoned, last release on October, 8th 2014.

S2Container.NET

S2Container.NET is another Dependency Injection framework that was ported from a Java library back in 2005. It is not widely-known and development was stopped in 2015.

Websitehttps://github.com/MicrosoftArchive/mef
Platforms.NET Framework 2.0
GitHubnot available
First released2005
NuGetnot available
DocumentationDocumentation
Developmentabandoned, last release 1.4.1 in 2015.

StructureMap

StructureMap logo

From the project website: “StructureMap is the oldest, continuously used IoC/DI container for .NET dating back to its first public release in June 2004 on .NET 1.1.”

As the grand-father of dependency injection frameworks, StructureMap offers feature-wise everything developers expect from a DI container: A modular configuration, lazy dependency resolution, resolution of IEnumerable types, diagnostics, and child container support. These features listed here are only a few selected features.

Meanwhile, StructureMap has been sunsetted as announced by Jeremy Miller on January 29th, 2018 and the maintainers recommend using Lamar as a possible replacement.

Websitehttp://structuremap.github.io/
Platforms.NET Framework 4.5, .NET Standard 1.6, Windows Phone (up to 8.1)
GitHub800+ Stars, 250+ Forks
First released2004
NuGet5.3M+ total downloads, 1.8K downloads per day (avg)
DocumentationDocumentation
Developmentdeprecated

Framework comparison

The following diagram shows the number of daily downloads the frameworks listed on NuGet.com get on average.

Remember, this is just a metric to show the current state, and it does not mean that the most popular framework is always the best choice for your project. Also, new projects that have not been there for a long time (e.g., Lamar) do not have that many downloads yet.

The numbers were taken from Nuget.com on January 24th, 2019.

Downloads per Day (avg.)

If there is a framework missing on this list or do you believe that some information is wrong? DM me on Twitter so that this list always stays current and complete.

Other Resources

PREMIUM CONTENT
Get access to my C#/.NET Bootcamp Course and 100+ additional software development courses by industry-leading instructors on Zero To Mastery.
Get 10% OFF with the code: FRIENDS10