At the risk of stepping into holy war territory, What are the strengths and weaknesses of these popular DI/IoC frameworks, and could one easily be considered the best? ..:
- Ninject
- Unity
- Castle.Windsor
- Autofac
- StructureMap
Are there any other DI/IoC Frameworks for C# that I haven't listed here?
In context of my use case, I'm building a client WPF app, and a WCF/SQL services infrastructure, ease of use (especially in terms of clear and concise syntax), consistent documentation, good community support and performance are all important factors in my choice.
Update:
The resources and duplicate questions cited appear to be out of date, can someone with knowledge of all these frameworks come forward and provide some real insight?
I realise that most opinion on this subject is likely to be biased, but I am hoping that someone has taken the time to study all these frameworks and have at least a generally objective comparison.
I am quite willing to make my own investigations if this hasn't been done before, but I assumed this was something at least a few people had done already.
Second Update:
If you do have experience with more than one DI/IoC container, please rank and summarise the pros and cons of those, thank you. This isn't an exercise in discovering all the obscure little containers that people have made, I'm looking for comparisons between the popular (and active) frameworks.
I came across another performance comparison(latest update 10 April 2014). It compares the following:
Here is a quick summary from the post:
You can also try using the Common Service Selector Library and hopefully try multiple options and see what works best for you.
Some informtion about Common Service Selector Library from the site:
Update
13.09.2011: Funq and Munq were added to the list of contestants. The charts were also updated, and Spring.NET was removed due to it's poor performance.
04.11.2011: "added Simple Injector, the performance is the best of all contestants".
See for a comparison of net-ioc-frameworks on google code including linfu and spring.net that are not on your list while i write this text.
I worked with spring.net: It has many features (aop, libraries , docu, ...) and there is a lot of experience with it in the dotnet and the java-world. The features are modularized so you donot have to take all features. The features are abstractions of common issues like databaseabstraction, loggingabstraction. however it is difficuilt to do and debug the IoC-configuration.
From what i have read so far: If i had to chooseh for a small or medium project i would use ninject since ioc-configuration is done and debuggable in c#. But i havent worked with it yet. for large modular system i would stay with spring.net because of abstraction-libraries.
Just read this great .Net DI container comparison blog by Philip Mat.
He does some thorough performance comparison tests on;
He recommends Autofac as it is small, fast, and easy to use ... I agree. It appears that Unity and Ninject are the slowest in his tests.
Actually there are tons of IoC frameworks. It seems like every programmer tries to write one at some point of their career. Maybe not to publish it, but to learn the inner workings.
I personally prefer autofac since it's quite flexible and have syntax that suits me (although I really hate that all register methods are extension methods).
Some other frameworks:
While a comprehensive answer to this question takes up hundreds of pages of my book, here's a quick comparison chart that I'm still working on:
Disclaimer: As of early 2015, there is a great comparison of IoC Container features from Jimmy Bogard, here is a summary:
Compared Containers:
The scenario is this: I have an interface, IMediator, in which I can send a single request/response or a notification to multiple recipients:
I then created a base set of requests/responses/notifications:
I was interested in looking at a few things with regards to container support for generics:
Setup for generic variance (registering handlers for base INotification/creating request pipelines) My handlers are pretty straightforward, they just output to console:
Autofac
Ninject
Simple Injector
StructureMap
Unity
Windsor