Comparison (pros/cons) of various .NET dependency injection frameworks

14,194

Solution 1

Here is a nice performance benchmark:

Solution 2

Actually there are two comprehensive comparisons already:

I personally prefer Ninject as it favors convention over configuration. It also makes use of lambda expressions and other C# 3.0 goodies (at a cost of .net 2.0) which makes it's syntax crystal clear.

Share:
14,194

Related videos on Youtube

KP Taylor
Author by

KP Taylor

I'm an applications and solutions architect and long-time coder in Atlanta, GA.

Updated on January 11, 2020

Comments

  • KP Taylor
    KP Taylor over 4 years

    I am in the process of selecting a dependency injection framework for a new .NET application. There is a bewildering plethora of these frameworks out there, including Ninject, StructureMap, Unity, Castle Windsor, Spring.NET, etc., etc. I never believe that any one tool is absolutely better or worse than any other, however; it always depends on context and constraints.

    With that in mind, can anyone offer some pros and cons of the various .NET dependency injection frameworks, vis-a-vis each other? Which are more suitable for small projects, large projects, etc.? For what types of projects, architectures, and development teams do each work best or not so well? Any wisdom from those who have worked with several of these frameworks would be very helpful...

  • STW
    STW about 13 years
    MEF isn't mentioned in either article, however it is another good candidate to consider.
  • KP Taylor
    KP Taylor about 13 years
    @Teoman I've read the Hanselman article before; it does list some general characteristics of the various frameworks (as of 2008, too, so it is a bit dated), but doesn't really put them head-to-head in a project/application context. I had not seen the Rich Newman series, and you're right, it is comprehensive! ...but it doesn't look at some popular frameworks for .NET like StructureMap, Ninject, etc. Still, +1 for a helpful answer....
  • Teoman Soygul
    Teoman Soygul about 13 years
    and +1 for good question:) As far as I see, Ninject is the neatest IoC container but as it is relatively new (especially the 2.0 release which made it really competitive), there are not many reviews on it..
  • Phill
    Phill about 13 years
  • KP Taylor
    KP Taylor about 13 years
    @Teoman I have recently used Ninject 2.0 and was very happy with it...but I keep seeing a lot of lip service being given to StructureMap (especially) followed by a few others, which is what got me wondering.
  • Phill
    Phill about 13 years
    @Ken - Personally I prefer StructureMap, they are all much of a muchness.
  • richard
    richard about 13 years
    @Teoman: What do you mean Ninject favors convention over configuration?
  • Teoman Soygul
    Teoman Soygul about 13 years
    @Richard DesLonde I mean you can get singleton instance with a single line of code (convention) where as with Castle you would be settings properties first and calling the getter afterwards (which is configuration).
  • richard
    richard about 13 years
    @Teoman: I understand the use of the word configuration, but not convention. What does it mean that its convention? Sorry to be so dull . . .
  • Teoman Soygul
    Teoman Soygul about 13 years
  • KP Taylor
    KP Taylor about 13 years
    That is a great comparison! Thanks!
  • jcolebrand
    jcolebrand about 12 years
    this link is no longer available.
  • Roy B
    Roy B almost 8 years
    The Zohosheets that are in the article displays "Sorry we could not process your request"

Related