DI Containers – comparison

By on (tags: IoC, categories: None)

This blog shortly describes a few chosen DI containers and their out-of-the-box functionality. If a certain container does not have a specific platform listed, it doesn’t necessarily mean that it’s not possible to use it there – it just means that it’s not in the box.

Castle Windsor

License: Apache 2
Target platforms: .Net, Silverlight
Complexity: Castle.Core, Castle.Windsor + facilities (plugins)
Acceptance: 3500 downloads nuget, 8600 downloads site
Age: ver 2.0 in 2009
Last Release: 02.2011
Features:

  • configurable in xml
  • autodiscovery
  • well documented

Sample code:

StructureMap

License: Apache 2
Target platforms: .Net
Complexity: StructureMap, StructureMap.AutoMocking (for unit tests)
Acceptance: 3500 downloads nuget, 10 000+ downloads site
Age: since 2004
Last Release: 02.2010
Features:

  • configurable in xml
  • autodiscovery (extensive)

Sample code:

Spring.Net

License: Apache 2
Target platforms: .Net, MVC, WCF,
Complexity: Spring.Core.Configuration
Acceptance: 60 downloads nuget
Age: since 2007
Last Release: 12.2010
Features:

  • configurable in xml

Sample code:

Autofac

License: MIT
Target platforms: .Net, MEF, MVC, WCF, WEB, Community, Silverlight
Complexity: Autofac, Autofac.Configuration + (MEF, MVC, WCF, WEB and community Prism, WCF Ria Services, Log4Net)
Acceptance:  3000 downloads nuget, 800+ downloads site
Age:
Last Release: 03.2011
Features:

  • confugurable in xml
  • autodiscovery

Sample code:

Unity

License: MS-PL
Target platforms: .Net, Silverlight
Complexity: Microsoft.Practices.ServiceLocation, Microsoft.Practices.Unity, Microsoft.Practices.Unity.Configuration, Microsoft.Practices.Unity.Interception, Microsoft.Practices.Unity.Interception.Configuration
Acceptance: 4000 downloads nuget, 50 000+ downloads site
Age: since 2005
Last Release: 05.2010 (seems out of data – projects fo vs 2008)
Features:

  • configurable in xml
  • autodiscovery

Sample code: