I'm looking to start a new application and I want to use Dependency Injection. I have a lot of "Microsoft is the only way to go guys" in our shop so of course Unity is the way they wanted to go. However I am leaning more towards Autfac because of its speed and its Module feature. I found the speed results on this page.

If you use Autofac or Unity can you give me some solid reasons not to use Unity and to use Autofac over Unity? If not, can you point me into a good direction to do some research on bringing back to our next meeting?

closed as off-topic by user40980, gnat, GlenH7, Kilian Foth, Martijn Pieters Jan 18 '15 at 2:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, GlenH7, Kilian Foth, Martijn Pieters
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Because you haven't heard of StructureMap? – Michael Brown Mar 29 '11 at 14:59
  • Once you've got used to the power that something like StructureMap provides, Unity seems pretty pathetic. Unfortunately, I've been suck (for "its from MS" reasons) using Unity for 2 years. Yuck. – Simon Mar 13 '12 at 16:13
  • What advantages does StructureMap have over autofac? – Stephen Jan 15 '15 at 5:18

I think speed is a red herring here -- if the speed of your IoC container is make or break for your project, you probably should not be using an IoC container in the first place. Moreover, these days most containers are so close in terms of features there really isn't a difference there -- unless there is something very specific you need out of it and only one option is capable of handling that. Best way to decide is experience -- if anyone has successfully implemented something non-trivial using IoC, I'd run with that one as the devil is in the details and you will have funny bugs that require some intimate knowledge of the way your IoC functions.


I doubt you will get any solid reasons on why to use one over the other; it comes down to opinion, warm fuzzy feelings, etc...

The performance measurements you linked to are certainly data points but the argument is moot. Performance across the board is close enough to not warrant that as a consideration when choosing the framework; which was noted in your linked to article.

My conclusion is the same as after the first test, the performance difference is not significant to warrant consideration when choosing a IoC container. Unless you create a incredibly large amount of transient components (not recommended), then maybe use Autofac...

I currently use Unity within Prism and have enjoyed it thus far. It too has a module component as well as other application blocks you can leverage. Perhaps you should give Prism a look as it may contain other components which you may want to leverage downstream.

In addition Prism has a large community around it; which is always beneficial in understanding the framework and getting assistance when needed.

  • Thanks, I took a look at Prism and looks cool, if we go this way I will dig deep into that. – Mark Mar 29 '11 at 19:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.