Comparison (pros/cons) of various .NET dependency injection frameworks
Solution 1
Here is a nice performance benchmark:
Solution 2
Actually there are two comprehensive comparisons already:
- This one lists all adding brief notes on their strong sides: http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx
- This one actually is a 4-part article series: http://richnewman.wordpress.com/2010/04/29/a-comparison-of-some-dependency-injection-frameworks-part-1-introduction-and-motivation/
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.
Related videos on Youtube
KP Taylor
I'm an applications and solutions architect and long-time coder in Atlanta, GA.
Updated on January 11, 2020Comments
-
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...
-
Mark Seemann about 13 yearsDuplicate: stackoverflow.com/questions/4581791/…
-
-
STW about 13 yearsMEF isn't mentioned in either article, however it is another good candidate to consider.
-
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 about 13 yearsand +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 about 13 years
-
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 about 13 years@Ken - Personally I prefer StructureMap, they are all much of a muchness.
-
richard about 13 years@Teoman: What do you mean Ninject favors convention over configuration?
-
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 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 about 13 years@Richard DesLonde well read it here: stackoverflow.com/questions/448266/… and here: en.wikipedia.org/wiki/Convention_over_configuration
-
KP Taylor about 13 yearsThat is a great comparison! Thanks!
-
jcolebrand about 12 yearsthis link is no longer available.
-
Roy B almost 8 yearsThe Zohosheets that are in the article displays "Sorry we could not process your request"