Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

differences between IoC containers

I'm looking for some guidance about how to chose an IoC container for an ASP.NET MVC application.

What are the differences between (for example) StructureMap, Ninject, Castle Windsor, Unity, autofac and others? Can anyone give some hints or links to resource that might help chosing one library?

Update: there is one question (Enterprise Library Unity vs Other IoC Containers) which talks about the differences in the initialization of the IoC containers.

But are there any differences in functionality, which would make some IoC containers a better choice for an ASP.NET MVC application?

like image 200
M4N Avatar asked Oct 28 '09 20:10

M4N


2 Answers

One thing which is different between the various IoC containers are the lifecycle or instantiation modes which are supported out of the box (when to create a new instance of the component):

  • StructureMap
    • transient (called per-request), singleton, thread-local, per-HttpContext, per-HttpSession, Hybrid
  • Ninject
    • transient, singleton, per-thread, per-HttpRequest
  • Castle windsor
    • singleton, transient, per-thread, pooled, per-HttpRequest (additional available through facilities)
  • autofac
    • transient (factory), singleton, per-HttpRequest
  • Unity
    • transient, singleton, per-thread
like image 186
M4N Avatar answered Oct 12 '22 10:10

M4N


Here's a helpful blog post that compares features between the various IOC frameworks available in .Net, I don't know that there's anything about MVC that favors one container over another though.

Max

like image 37
MadMax1138 Avatar answered Oct 12 '22 09:10

MadMax1138