Take the 2-minute tour ×

I'd like to start using IoC Container in an existing WPF application.
I need good performance, but from what I read, performance is really not an issue with most containers.
What I need most is a very easy to use container, that can be easily integrated into my app. I read recommendations about StructureMap (and the syntax looks great), but in their site it seems that there were no updates in the last 3 years, so I'm having some doubts about it.

Please provide recommendations with basic usage code samples (initialization + usage).

I'm not looking for a complete framework. I only need the IoC container ability, so many other alternatives exist. The last relevant discussion I found here is a few years old and I'd like to refresh it.

share|improve this question
possible duplicate of What MVVM framework are you using? –  slugster Feb 24 '13 at 7:12
Easy and fast? Try Simple Injector (shameless plug). –  Steven Feb 24 '13 at 12:24
I read about Simple Injector and saw it runs on SilverLight. Will there be any problem in WPF apps? –  Noich Feb 24 '13 at 13:22
add comment

3 Answers

up vote 1 down vote accepted

The answer really depends on personal preference and the details of your use case. Anyway, after using Unity, MEF (I know, not a real IoC container) and writing some individual solutions, I am now using Autofac and like it a lot. It is very easy to dig into and continuously reveals its advantages the longer you use it. It provides a fluent interface and is fast, compared to other frameworks (btw: The performance of your container can be a very important issue, depending on what you want to do). For usage and samples of Autofac see the link above.

Why I like it:

Still, this is personal choice and there are other good solutions around, which might even be better for your special case.

And, more or less off-topic, I can recommend this article, especially the second half, for general considerations. It helped me a lot. So, just in case:

Article by Martin Fowler

share|improve this answer
Thanks for the helpful answer. I read Fowler's article. The main resistance to using a container in our code is because it's "black magic". I want to show that it is very easy to use and understand. –  Noich Feb 27 '13 at 12:14
@Noich: It IS black magic! So be a magician ;) –  Marc Mar 7 '13 at 8:49
Black magic is frowned upon. :/ I'd really like to be the magician though. –  Noich Mar 7 '13 at 8:57
@Noich: True, if you look at it historically, it has always been a bit of an issue to be a magician. Anyway, it's all about knowing your tricks. Good luck! –  Marc Mar 7 '13 at 9:11
add comment

Your question is a shopping-list type question so it won't stay open long.

There are a number of IoC type frameworks, some of which require declarative or programmatic manipulation to do their work, some of which use code semantics to wire things up.

I would suggest you start with Unity1 until you get into the swing of things, then look to branch out into some of the more exotic frameworks when you can appreciate the differences between them.

1 Here is a good recent intro article: Visual Studio magazine: Creating Modularity with WPF, Prism and Unity

share|improve this answer
add comment

Structuremap aint dead.

We are using it for our new green field project, and when v3 is out we may migrate to it. ATM using 2.6.4.

share|improve this answer
add comment

Your Answer


