Dependency Injection

General information

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Version 3.5.2 3.3.0 4.4.0 2.4.3 3.0.2.0 2.2.0.45 5.1.0 2.0.0 0.8.1 1.5.1 4.0.9 2.3.0.41559 4.0.0.0 2.1.6.0 3.5.1 3.1.6 3.2.2.0 3.1.4 2.0.1 2.1.1 4.2.0.402 1.3 4.0.1
Released aug 2014 may 2014 nov 2015 may 2016 may 2013 apr 2015 feb 2017 mar 2014 nov 2013 feb 2013 apr 2016 mar 2012 n/a jun 2012 mar 2013 apr 2012 apr 2014 may 2016 apr 2015 feb 2017 may 2016 dec 2014 oct 2015
Distribution binary binary binary binary binary binary binary binary binary binary binary binary built-in binary binary binary binary binary binary binary binary source binary
Web Site link link link link link link link link link link link link n/a link link link link link link link link link link
License MIT Apache MIT MIT n/a n/a MIT Apache BSD unrecognized MIT LGPL-3.0 n/a MIT MS-PL MS-PL Apache MIT Apache MIT Apache 404 Apache
Downloads 4 196 409 1 521 734 156 558 61 720 7 922 14 228 14 311 4 300 2 451 5 628 195 255 5 520 n/a 4 305 5 593 14 876 4 187 352 991 045 156 843 6 514 1 759 903 90 733 5 555 707
Total Score 92% 96% 44% 100% 32% 36% 100% 40% 32% 56% 88% 52% 48% 40% 76% 52% 60% 60% 44% 100% 76% 52% 72%

Supported .NET versions

This information is based on versions included in NuGet package.

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
netstandard1.0 no no no no no no yes no no no no no n/a no no yes no no no yes no yes no
.NET 2.0 no no no no no no no no no no no no n/a no yes yes no no no no no yes no
.NET 3.5 no yes no yes no no no yes no yes no yes n/a no yes yes yes no yes no no yes no
.NET CF 3.5 no no no no no no no no no yes no no n/a no no yes no no no no no yes no
.NET 3.5 (Client Profile) no yes no yes no no no yes no yes no yes n/a no yes yes yes no yes no no yes no
.NET 4.0 yes yes yes yes yes yes no yes no yes no yes n/a yes yes yes yes yes yes no yes yes no
.NET 4.0 (Client Profile) yes yes yes yes yes yes no yes no yes no yes n/a yes yes yes yes yes yes no yes yes no
.NET 4.5 yes yes yes yes yes yes yes yes yes yes yes yes n/a yes yes yes yes yes yes yes yes yes yes
.NET 4.5.1 yes yes yes yes yes yes yes yes yes yes yes yes n/a yes yes yes yes yes yes yes yes yes yes
.NET 4.6 yes yes yes yes yes yes yes yes yes yes yes yes n/a yes yes yes yes yes yes yes yes yes yes
Windows 8 yes no yes yes no yes yes no yes no yes no n/a yes yes yes no yes no yes yes yes yes
Windows 8.1 yes no yes yes no yes yes no yes no yes no n/a yes yes yes no yes no yes yes yes yes
Windows Universal (8.1) yes no yes yes no no yes no no no yes no n/a no no yes no yes no yes no yes yes
Universal Windows Platform 10.0 no no yes no no no no no no no no no n/a no no yes no no no no no yes no
Windows Phone 7 no no no no no no no no no no no no n/a no no yes yes no no no no yes no
Windows Phone 7.1 no no no no no no no yes yes no no no n/a no yes yes yes no no no no yes no
Windows Phone 8.0 yes no yes yes no yes yes yes yes no no no n/a no yes yes yes yes no yes yes yes yes
Windows Phone 8.1 yes no yes yes no yes yes yes yes no no no n/a no yes yes yes yes no yes yes yes yes
Silverlight 2 no no no no no no no no no no no no n/a no no yes yes no no no no yes no
Silverlight 3 no no no no no no no no no yes no no n/a no no yes yes no no no no yes no
Silverlight 4 no yes no no no no no yes yes yes no no n/a yes yes yes yes yes no no no yes no
Silverlight 5 yes yes yes yes no no no yes yes yes no no n/a yes yes yes yes yes no no no yes no
dnx 4.5.1 yes yes yes yes yes yes yes yes yes yes yes yes n/a yes yes yes yes yes yes yes yes yes yes
dnxcore 5.0 no no no no no no no no no no yes no n/a no no yes no no no no no yes no
dotnet no no no yes no no no no no no no no n/a no no yes no yes no no yes yes no
MonoAndroid no no yes no no no no no no no no no n/a no no yes no no no no no yes no
MonoAndroid 1.0 yes no yes yes no no no no no no no no n/a no no yes no no no no no yes yes
MonoAndroid 1.6 yes no yes yes no yes no no no no no no n/a no no yes no no no no no yes yes
MonoTouch 1.0 yes no no yes no no no no no no no no n/a no no yes no no no no no yes yes
MonoTouch 4.0 yes no yes yes no yes no no no no no no n/a no no yes no no no no no yes yes
Xamarin iOS 1.0 no no yes no no no no no no no no no n/a no no yes no no no no no yes no

Essential functionality

These are the basic features that should be supported by all frameworks.

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Register/resolve independent service pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass
Register/resolve independent service registered as itself pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass
Singleton lifetime pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass
Transient lifetime pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass
Register/resolve instance pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass
Resolve constructor dependency pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass
Resolve constructor dependency using instance pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass pass

List/array dependencies

When several registrations of IService exist in a container, many frameworks automatically provide IService[] (or List<IService> etc).

This is extremely important for open/closed principle. For example, UserValidator can have dependency on IUserValidationRule[]. Then new rules can be transparently added to the system without any changes to UserValidator.

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
IService[] pass pass fail pass fail fail pass fail fail fail pass pass pass fail pass fail pass pass pass pass pass fail pass
IList<IService> pass pass fail pass fail fail pass fail fail pass pass fail fail fail pass fail pass pass pass pass pass fail fail
ICollection<IService> pass pass fail pass fail fail pass fail fail pass pass fail fail fail pass fail pass pass fail pass fail fail fail
IEnumerable<IService> pass pass fail pass fail fail pass pass fail pass pass pass pass fail pass fail pass pass fail pass pass fail fail
IReadOnlyCollection<IService> pass pass fail pass fail fail pass fail fail pass pass fail fail fail fail fail fail pass fail pass fail fail fail
IReadOnlyList<IService> pass pass fail pass fail fail pass fail fail pass pass fail fail fail fail fail fail pass fail pass fail fail fail

Open generics

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Open generic registration pass pass pass pass fail fail pass pass fail pass pass pass pass fail pass pass pass pass fail pass pass pass pass
Constraint support for open generics pass pass n/a pass n/a n/a pass fail n/a fail pass fail fail n/a fail n/a fail fail n/a pass pass n/a n/a

Optional parameters

Optional parameters can be used to specify an optional dependency, e.g.

Service(IService required, IOptionalService optional = null)

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Missing primitive pass pass fail pass fail fail pass fail fail fail fail fail fail fail pass fail pass fail fail pass pass fail fail
Missing primitive with default value pass pass n/a pass n/a n/a pass n/a n/a n/a n/a n/a n/a n/a pass n/a pass n/a n/a pass pass n/a n/a
Missing dependency pass pass fail pass fail fail pass fail fail fail fail fail fail fail pass fail fail fail fail pass fail fail fail

Func<TService>

When TService is registered in a container, many frameworks automatically provide Func<..., TService>.

This is very useful for mixing lifetimes: for example, singleton (Service) may have a Func dependency on transient (DataContext), which allows it to get/dispose a new instance of transient when it is needed.

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
No parameters pass pass fail pass fail fail pass fail fail pass pass fail fail fail pass fail note fail fail pass pass pass pass
Parameter for dependency pass pass n/a pass n/a n/a pass n/a n/a pass fail n/a n/a n/a fail n/a note n/a n/a pass pass fail fail
Parameter for subdependency fail fail n/a pass n/a n/a pass n/a n/a fail n/a n/a n/a n/a n/a n/a note n/a n/a pass pass n/a n/a
Singleton using transient pass pass n/a pass n/a n/a pass n/a n/a pass pass n/a n/a n/a pass n/a note n/a n/a pass pass pass pass

Lazy<TService>

When TService is registered in a container, some frameworks automatically provide Lazy<TService>.

This might be useful for expensive initialization or resolution of circular dependencies (you should not have those btw).

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Basic support pass pass fail pass fail fail pass fail fail pass pass fail fail fail pass fail fail fail fail pass pass pass pass
Not created prematurely pass pass n/a pass n/a n/a pass n/a n/a pass pass n/a n/a n/a pass n/a n/a n/a n/a pass pass pass pass
Circular dependency pass pass n/a pass n/a n/a pass n/a n/a pass pass n/a n/a n/a pass n/a n/a n/a n/a pass pass pass pass

Property dependencies

While property dependencies are a nice feature, it is rarely a good practice to actually use them.

I have not yet decided whether this table is worth keeping, so do not assign much weight to these tests.

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Simple dependency pass pass fail pass fail fail pass fail pass fail pass pass pass fail pass fail pass note pass pass pass fail pass
Optional by default pass pass n/a pass n/a n/a pass n/a fail n/a pass pass fail n/a fail n/a fail note pass pass fail n/a fail
Dependency without attributes pass pass n/a pass n/a n/a pass n/a fail n/a pass fail pass n/a fail n/a fail note pass pass fail n/a fail

Request lifetime

Web applications are a very common use for DI containers.
For those, a per-web-request lifetime can be very useful (for things like ORM sessions and transactions).
Note that it is not the same as per-thread lifetime, as the request can potentially switch threads.

This feature is often a more limited version of child container/scope feature, but as it is more widely supported and more obviously useful, for now I focus only on web requests.

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Basic support pass pass fail pass fail fail pass fail fail fail pass fail fail pass pass pass pass pass note pass fail fail pass
Instance is reused within request pass pass n/a pass n/a n/a pass n/a n/a n/a pass n/a n/a fail pass pass note pass n/a pass n/a n/a pass
Instance is not reused between requests pass pass n/a pass n/a n/a pass n/a n/a n/a pass n/a n/a pass pass pass note pass n/a pass n/a n/a pass
Instance is disposed at the end of request pass pass n/a pass n/a n/a pass n/a n/a n/a pass n/a n/a fail fail pass note pass n/a pass n/a n/a pass
Singleton using factory does not reuse instance between requests fail pass n/a pass n/a n/a pass n/a n/a n/a pass n/a n/a n/a fail n/a n/a n/a n/a pass n/a n/a pass

Convenience

Features that simplify development and reduce surprises.

Name Autofac Castle Catel DryIoc Dynamo.Ioc Endjin Composition Grace HaveBox IfInjector LightCore LightInject LinFu MEF MicroSliver Mugen Munq Ninject Simple Injector Spring.NET Stashbox StructureMap TinyIoC Unity
Best constructor selection pass pass pass pass fail pass pass fail fail pass pass pass fail fail fail fail pass note fail pass fail pass fail
Registration at any stage pass pass pass pass pass pass pass pass fail fail pass pass pass pass pass pass pass note pass pass pass pass pass
Graceful recursion handling pass pass pass pass fail fail pass fail pass fail pass pass pass fail pass fail pass pass pass pass pass fail fail
Graceful recursion handling (list dependency) pass pass n/a pass n/a n/a pass n/a n/a n/a pass pass pass n/a pass n/a pass pass pass pass pass n/a fail

Not tested

List of containers I couldn't test, with corresponding reasons.

fFastInjector
Static only: would require an AppDomain to test properly.
Funq
Not found on NuGet.
Griffin
Complex API. Please feel free to do a pull request for it.
Hiro
Complex API.
Petite
Code-only NuGet package.
Speedioc
I can't quickly figure out how to register an instance.
Stiletto
Seems to use attribute-only registration.