List of .NET Dependency Injection Containers (IOC)
Sponsored By
I'm trying to expand my mind around dependency injection in .NET (beyond the two frameworks I've personally used) and an starting to put together a list of .NET Dependency Injection Containers and IOC resources.
Here's what I've got so far. What am I missing?
- Castle Windsor based on the Castle MicroKernel.
- Licensed under Apache 2
- Currently 1.0 RC3
- Well documented and used by many.
- StructureMap has been around since June 2004
- Licensed under Apache 2
- Actively developed and approaching v2.5.
- Written by Jeremy D. Miller
- Spring.NET
- Licensed under Apache 2
- Currently 1.1, working on 2.0
- Written by Mark Pollack
- Autofac intends to be IoC with a C# 3.0 flavor, but also supports 2.0.
- Licensed under MIT
- Written by Nicholas Blumhardt and Rinat Abdullin
- Unity
- Licensed as MS-PL
- Recently released
- Written by Chris Tavares.
- Build on the "kernel" of ObjectBuilder:
- ObjectBuilder was formerly MSFT's only public foray into DI/IoC
- Custom PnP License, more restrictive than MS-PL
- Part of the MS PnP group
- Written by Brad Wilson, Peter Provost and Scott Densmore
- Puzzle.NFactory
- Licensed under the Lesser GPL
- Part of the larger Puzzle Framework
- Written by Roger Alsing and Mats Helander
- Ninject formerly "Titan"
- Licensed under Apache 2
- Was quiet, but has recently sprung back to life.
- Written by Nate Kohari
- S2Container.NET on version 1.3.7.
- Port of Java's Seasar2
- PicoContainer.NET
- Port of Java's PicoContainer
- Written by Aslak Hellesøy
- LinFu
- Licensed under Lesser GPL
- Written by Philip Laureano
- Hacked DIY (Do It Yourself)
- There are many examples of quicky IOC Containers. Interesting for learning but little else.
- Oren Eini's IOC in 15 lines and a follow up in Ken Egozi's IOC in 15 lines
- There are many examples of quicky IOC Containers. Interesting for learning but little else.
What projects have I forgotten? Thanks!
Related Links
- IOC and Unity compared to other containers
- Introduction to using StructureMap for Dependency Injection
- Dependency Injection with Spring.NET
- Context Variables in Ninject
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
And btw, Castle Windsor (as the rest of the Castle Project) is licensed under Apache License 2.0
There is also the Seasar DI Container, however I'm not sure what license it falls under.
Checkout http://s2container.net.seasar.org
Checkout http://s2container.net.seasar.org
PicoContainer.NET
(And remembering to double check the section of Windows Developer Power tools which has one of the best intros I've read on DI as well as a mention of the above :P)
(And remembering to double check the section of Windows Developer Power tools which has one of the best intros I've read on DI as well as a mention of the above :P)
Why on earth do Redmond not produce anything original.
Why do we need another IOC container aka Unity.
I love the CLR. I love the way it is evolving uniquely.
I am saddened by the 0 amount of innovation coming out of Redmond.
What have been their recent projects:
ASP.NET MVC - Read Monorail
Unity - Read the above.
I sincerely hop Unity is better than ObjectBuilder but why on earth would I choose it over Castle.
These guys should be ground breaking or Microsoft should be hiring some talent to set the standard.
I use open source because the tools are better. End of storty. If the MS tools were better I would switch instantly.
Why do we need another IOC container aka Unity.
I love the CLR. I love the way it is evolving uniquely.
I am saddened by the 0 amount of innovation coming out of Redmond.
What have been their recent projects:
ASP.NET MVC - Read Monorail
Unity - Read the above.
I sincerely hop Unity is better than ObjectBuilder but why on earth would I choose it over Castle.
These guys should be ground breaking or Microsoft should be hiring some talent to set the standard.
I use open source because the tools are better. End of storty. If the MS tools were better I would switch instantly.
I didn't use ObjectBuilder a lot, but seems to me that it's not a full-blown IoC.
From my experience with it, it is "just" a DI framework, without the container.
Good enough that now the PnP build Unity :)
From my experience with it, it is "just" a DI framework, without the container.
Good enough that now the PnP build Unity :)
A great 4 part article on IoC by Simone Busoli can be found here
It gives a very good explanation of the power and usefulness of IoC.
Enjoy
It gives a very good explanation of the power and usefulness of IoC.
Enjoy
Hi Scott,
Don't forget about The LinFu Framework, which has an IoC container of its own, not to mention some of the other following features:
* Aspect-Oriented Programming
* Dynamic Proxies
* Late Binding
* Mixins
* Universal Event Handling
* Closures with Lambda Arguments
* Duck Typing
* Design by Contract
If you get the chance, take a look at it and let me know what you think. Thanks!
Don't forget about The LinFu Framework, which has an IoC container of its own, not to mention some of the other following features:
* Aspect-Oriented Programming
* Dynamic Proxies
* Late Binding
* Mixins
* Universal Event Handling
* Closures with Lambda Arguments
* Duck Typing
* Design by Contract
If you get the chance, take a look at it and let me know what you think. Thanks!
Would be nice to see some example scenarios and how ioC framework each tackles it at code level.
[)amien
[)amien
Scott,
This autofac project page holds some articles on autofac container and all the related links for the project.
Autofac IoC container fits really well into the usage scenarios of complex application and UI composition. And the core is really lighweight. That's the primary reason I fell in love with it. Others are: deterministic component disposal, proper component resolution within the nested scopes (that's what had driven me away from the Castle), elegant lambda syntax for complex registration scenarios.
Additionally ORM+IoC and xLim2 series might give you some insight on what could be efficiently done with this IoC container.
Please, feel free to ask questions, if you have any.
Best regards,
Rinat Abdullin
This autofac project page holds some articles on autofac container and all the related links for the project.
Autofac IoC container fits really well into the usage scenarios of complex application and UI composition. And the core is really lighweight. That's the primary reason I fell in love with it. Others are: deterministic component disposal, proper component resolution within the nested scopes (that's what had driven me away from the Castle), elegant lambda syntax for complex registration scenarios.
Additionally ORM+IoC and xLim2 series might give you some insight on what could be efficiently done with this IoC container.
Please, feel free to ask questions, if you have any.
Best regards,
Rinat Abdullin
PS: context variables and transient (container-scoped components) represent common usage scenario in autofac. Resolving some transient component (registered in root container) in child container (with any depth of nesting) will fill in the dependencies from this child container first.
Thanks for mentioning Ninject in such great company. There'll be some new features coming in the near future now that I've been able to scrounge some more time to work on it. Hopefully some better documentation too. :)
Are there any IoC frameworks out there for the Compact Framework? I have spent some time looking but havn't found anything yet. This seems to leave two options, roll my own from scratch, or pick one of the existing IoC frameworks out there and try to port it over. I would love to hear opinions on which framework might be the easiest to port.
I wrote a simple (and free) service locator for DI that is described at here, and the code is available for download. It's a relatively simple implementation, but if you're new to new to DI/IoC, you might be interested in seeing how it works.
Hey Scott, I look forward to see what kind of conclusions you come to. I am still meaning to play around w/ some of the other frameworks you mention, however, StructureMap is my current IoC framework of choice. I wrote a Simple Dependency Injection with StructureMap tutorial to hopefully help anyone who has not used it before. Regards!
Some updates and an answer to a question from above:
I didn't work on the original ObjectBuilder; that was Scott, Brad, & Peter Provost. Unity is being built on top of OB; OB : Unity <-> Castle Microkernel : Castle Windsor. Also, Unity isn't quite released yet; we've got a week or so to go to 1.0.
@Adam Salvo:
You might want to check out the Mobile Client Software Factory at http://msdn2.microsoft.com/en-us/library/aa480471.aspx. The main reason is that the team did a lot around DI with objectbuilder on the mobile platform. They discovered that reflection is HELLISHLY expensive on WinCE, so they wrote a preprocessing tool called obgen that does the reflection required at compile time, and generates the code to assemble objects. Might be worth checking out.
I didn't work on the original ObjectBuilder; that was Scott, Brad, & Peter Provost. Unity is being built on top of OB; OB : Unity <-> Castle Microkernel : Castle Windsor. Also, Unity isn't quite released yet; we've got a week or so to go to 1.0.
@Adam Salvo:
You might want to check out the Mobile Client Software Factory at http://msdn2.microsoft.com/en-us/library/aa480471.aspx. The main reason is that the team did a lot around DI with objectbuilder on the mobile platform. They discovered that reflection is HELLISHLY expensive on WinCE, so they wrote a preprocessing tool called obgen that does the reflection required at compile time, and generates the code to assemble objects. Might be worth checking out.
I have an open source framework called SharpCore hosted on CodePlex that has an IoC implementation. It was written mainly as an exercise in understanding what makes them work; plus, it was a lot of fun to write!
You can check it out here: http://www.codeplex.com/SharpCore
You can check it out here: http://www.codeplex.com/SharpCore
You missed out XAML :-) It's an object builder language - and therefore a dependency injection system.
@Adam: I wrote a version of Ninject for the .NET compact framework for a project at work. My plan is to clean it up and release it along with the "full" fx version. I can send it to you if you like.
<plug type="shameless">
I just published an article on DI/IoC in the March 2008 issue of MSDN Magazine. The advanced examples use Windsor, but the point of the article is to explain the underlying concepts. So if you are wondering why DI/IoC matters, go read Loosen Up: Tame Your Software Dependencies for More Flexible Apps. In the article, I roll a simple DIY IoC in about the same number of lines as Oren's or Ken's. Just another example of how you can easily use DI/IoC concepts in your application even if you can't use a full-fledged IoC framework for political reasons.
</plug>
I just published an article on DI/IoC in the March 2008 issue of MSDN Magazine. The advanced examples use Windsor, but the point of the article is to explain the underlying concepts. So if you are wondering why DI/IoC matters, go read Loosen Up: Tame Your Software Dependencies for More Flexible Apps. In the article, I roll a simple DIY IoC in about the same number of lines as Oren's or Ken's. Just another example of how you can easily use DI/IoC concepts in your application even if you can't use a full-fledged IoC framework for political reasons.
</plug>
@Nate: I'd loved to take a look at Ninject for the compact framework. You can send it to adam at salvoz dot com, or let me know when you release it. Thanks.
@Chris: Thanks for the heads up on the mobile client software factory. I've see some references to it before but havn't looked at it in depth yet.
@Chris: Thanks for the heads up on the mobile client software factory. I've see some references to it before but havn't looked at it in depth yet.
Hi Scott,
Thanks for the comprehensive listings. Could you link to the Spring.NET home page, instead of our training page?
<editorial>I don't think it would be inaccurate to say that Spring.NET is also very well documented and widely used.</editorial>
Cheers,
Mark
Thanks for the comprehensive listings. Could you link to the Spring.NET home page, instead of our training page?
<editorial>I don't think it would be inaccurate to say that Spring.NET is also very well documented and widely used.</editorial>
Cheers,
Mark
LinFu
* Licensed under Lesser GPL
* Written by Philip Laureno
Dude, you spelled my last name wrong--it's "Laureano", not "Laureno"...
* Licensed under Lesser GPL
* Written by Philip Laureno
Dude, you spelled my last name wrong--it's "Laureano", not "Laureno"...
Thanks for the link, Scott.
Looking over this 'complete' list reminds me of Ayende's concern that DI containers are too often evaluated only on the merits of their DI capabilities - I take my hat off to any reviewer who can achieve even that much in such a broad field of libraries!
He's right, of course - the more interesting features usually only present themselves once you're into the thick of building an application. I don't think they're really make-or-break though.
My advice to anyone reading this and wondering where to start is not to focus too much on the libraries - dependency injection is a powerful coding style that will make a much bigger impact on the architecture of an application than the particular container will. Once you've mastered dependency injection itself you'll have a much clearer idea of the features you want from a container.
Interesting list, looking forward to hearing some more along this theme :)
Nick
Looking over this 'complete' list reminds me of Ayende's concern that DI containers are too often evaluated only on the merits of their DI capabilities - I take my hat off to any reviewer who can achieve even that much in such a broad field of libraries!
He's right, of course - the more interesting features usually only present themselves once you're into the thick of building an application. I don't think they're really make-or-break though.
My advice to anyone reading this and wondering where to start is not to focus too much on the libraries - dependency injection is a powerful coding style that will make a much bigger impact on the architecture of an application than the particular container will. Once you've mastered dependency injection itself you'll have a much clearer idea of the features you want from a container.
Interesting list, looking forward to hearing some more along this theme :)
Nick
Scott, out of curiosity, so far which have you to bee easiest/best to use.
RhysC
RhysC
ok my engerish is not so good...
Scott, out of curiosity, so far, which of the afore mentioned IoC containers have you found to be the easiest/best to use?
RhysC
Scott, out of curiosity, so far, which of the afore mentioned IoC containers have you found to be the easiest/best to use?
RhysC
@Adam: I have writen a lightweight IoC container that works under .NET Compact Framework 2. You can check it out at compactcontainer.googlecode.com
Hi Scott,
You could add our freshly released IoC container. Winter4net is fast, compact and scalable lightweight .NET inversion of control (IoC, dependency injection) container.
You could add our freshly released IoC container. Winter4net is fast, compact and scalable lightweight .NET inversion of control (IoC, dependency injection) container.
Comments are closed.
managerialdesign decision".People should realize that if they can't use one, the can always roll something simple to meet their needs.
Like when you want to have zero-dependency (but BCL).
Examples (shameless plug): Mine and Oren Eini's
Not great code, however usable.