Comparison (pros/cons) of various .NET dependency injection frameworks
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 a开发者_运维知识库lways 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...
Here is a nice performance benchmark:
- IoC Container Benchmark - Performance comparison
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.
精彩评论