<p>Which C#/.NET Dependency Injection frameworks are worth looking into?
And what can you say about their complexity and speed.</p>

[{'answer_id': 21296, 'author': 'ScottKoon', 'author_id': 1538, 'author_profile': 'https://Stackoverflow.com/users/1538', 'pm_score': 4, 'selected': False, 'text': "<p>Ninject is great. It seems really fast, but I haven't done any comparisons. I know Nate, the author, did some comparisons between Ninject and other DI frameworks and is looking for more ways to improve the speed of Ninject.</p>\n\n<p>I've heard lots of people I respect say good things about StructureMap and CastleWindsor. Those, in my mind, are the big three to look at right now.</p>\n"}, {'answer_id': 21310, 'author': 'Jason Sparks', 'author_id': 512, 'author_profile': 'https://Stackoverflow.com/users/512', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve used <a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.NET</a> in the past and had great success with it. I never noticed any substantial overhead with it, though the project we used it on was fairly heavy on its own. It only took a little time reading through the <a href="http://www.springframework.net/documentation.html#Reference_Manual_and_API" rel="nofollow noreferrer">documentation</a> to get it set up.</p>\n'}, {'answer_id': 21315, 'author': 'Ian Patrick Hughes', 'author_id': 2213, 'author_profile': 'https://Stackoverflow.com/users/2213', 'pm_score': 2, 'selected': False, 'text': '<p>The great thing about C# is that it is following a path beaten by years of Java developers before it. So, my advice, generally speaking when looking for tools of this nature, is to look for the solid Java answer and see if there exists a .NET adaptation yet.</p>\n\n<p>So when it comes to DI (and there are so many options out there, this really is a matter of taste) is <a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.NET</a>. Additionally, it\'s always wise to research the people behind projects. I have no issue suggesting SourceGear products for source control (outside of using them) because I have respect for Eric Sink. I have seen Mark Pollack speak and what can I say, the guy just gets it.</p>\n\n<p>In the end, there are a lot of DI frameworks and your best bet is to do some sample projects with a few of them and make an educated choice.</p>\n\n<p>Good luck! </p>\n'}, {'answer_id': 21348, 'author': 'RobertTheGrey', 'author_id': 1107, 'author_profile': 'https://Stackoverflow.com/users/1107', 'pm_score': 9, 'selected': True, 'text': '<p><strong>edit</strong> (not by the author): There is a comprehensive list of IoC frameworks available at <a href="https://github.com/quozd/awesome-dotnet/blob/master/README.md#ioc" rel="nofollow noreferrer">https://github.com/quozd/awesome-dotnet/blob/master/README.md#ioc</a>:</p>\n<ul>\n<li><a href="https://github.com/castleproject/Windsor" rel="nofollow noreferrer">Castle Windsor</a> - Castle Windsor is best of breed, mature Inversion of Control container available for .NET and Silverlight</li>\n<li><a href="https://github.com/unitycontainer/unity" rel="nofollow noreferrer">Unity</a> - Lightweight extensible dependency injection container with support for constructor, property, and method call injection</li>\n<li><a href="https://github.com/autofac/Autofac" rel="nofollow noreferrer">Autofac</a> - An addictive .NET IoC container</li>\n<li><a href="https://github.com/dadhi/DryIoc" rel="nofollow noreferrer">DryIoc</a> - Simple, fast all fully featured IoC container.</li>\n<li><a href="https://github.com/ninject/ninject" rel="nofollow noreferrer">Ninject</a> - The ninja of .NET dependency injectors</li>\n<li><a href="https://github.com/spring-projects/spring-net" rel="nofollow noreferrer">Spring.Net</a> - Spring.NET is an open source application framework that makes building  enterprise .NET applications easier</li>\n<li><a href="https://jasperfx.github.io/lamar/" rel="nofollow noreferrer">Lamar</a> - A fast IoC container heavily optimized for usage within ASP.NET Core and other .NET server side applications.</li>\n<li><a href="https://github.com/seesharper/LightInject" rel="nofollow noreferrer">LightInject</a> - A ultra lightweight IoC container</li>\n<li><a href="https://github.com/simpleinjector/SimpleInjector" rel="nofollow noreferrer">Simple Injector</a> - Simple Injector is an easy-to-use Dependency Injection (DI) library for .NET 4+ that supports Silverlight 4+, Windows Phone 8, Windows 8 including Universal apps and Mono.</li>\n<li><a href="https://github.com/aspnet/DependencyInjection" rel="nofollow noreferrer">Microsoft.Extensions.DependencyInjection</a> - The default IoC container for ASP.NET Core applications.</li>\n<li><a href="https://github.com/khellang/Scrutor" rel="nofollow noreferrer">Scrutor</a> - Assembly scanning extensions for Microsoft.Extensions.DependencyInjection.</li>\n<li><a href="https://github.com/Microsoft/vs-mef" rel="nofollow noreferrer">VS MEF</a> - Managed Extensibility Framework (MEF) implementation used by Visual Studio.</li>\n<li><a href="https://github.com/grumpydev/TinyIoC" rel="nofollow noreferrer">TinyIoC</a> - An easy to use, hassle free, Inversion of Control Container for small projects, libraries and beginners alike.</li>\n<li><a href="https://github.com/z4kn4fein/stashbox" rel="nofollow noreferrer">Stashbox</a> - A lightweight, fast and portable dependency injection framework for .NET based solutions.</li>\n</ul>\n<p>Original answer follows.</p>\n<hr />\n<p>I suppose I might be being a bit picky here but it\'s important to note that DI (Dependency Injection) is a programming pattern and is facilitated by, but does not require, an IoC (Inversion of Control) framework. IoC frameworks just make DI much easier and they provide a host of other benefits over and above DI.</p>\n<p>That being said, I\'m sure that\'s what you were asking. About IoC Frameworks; I used to use <a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.Net</a> and <a href="https://github.com/castleproject/Windsor/blob/master/docs/README.md" rel="nofollow noreferrer">CastleWindsor</a> a lot, but the real pain in the behind was all that pesky XML config you had to write! They\'re pretty much all moving this way now, so I have been using <a href="http://structuremap.github.io/" rel="nofollow noreferrer">StructureMap</a> for the last year or so, and since it has moved to a fluent config using strongly typed generics and a registry, my pain barrier in using IoC has dropped to below zero! I get an absolute kick out of knowing now that my IoC config is checked at compile-time (for the most part) and I have had nothing but joy with StructureMap and its speed. I won\'t say that the others were slow at runtime, but they were more difficult for me to setup and frustration often won the day.</p>\n<p><strong>Update</strong></p>\n<p>I\'ve been using <a href="http://ninject.org/" rel="nofollow noreferrer">Ninject</a> on my latest project and it has been an absolute pleasure to use. Words fail me a bit here, but (as we say in the UK) this framework is \'the Dogs\'. I would highly recommend it for any green fields projects where you want to be up and running quickly. I got all I needed from a <a href="http://www.dimecasts.net/Casts/ByAuthor/Justin%20Etheredge" rel="nofollow noreferrer">fantastic set of Ninject screencasts</a> by Justin Etheredge. I can\'t see that retro-fitting Ninject into existing code being a problem at all, but then the same could be said of <a href="http://structuremap.github.io/" rel="nofollow noreferrer">StructureMap</a> in my experience. It\'ll be a tough choice going forward between those two, but I\'d rather have competition than stagnation and there\'s a decent amount of healthy competition out there.</p>\n<p>Other IoC screencasts can also be found <a href="http://www.dimecasts.net/Casts/ByTag/IoC" rel="nofollow noreferrer">here on Dimecasts</a>.</p>\n'}, {'answer_id': 21524, 'author': 'Pete', 'author_id': 76, 'author_profile': 'https://Stackoverflow.com/users/76', 'pm_score': 5, 'selected': False, 'text': '<p>Autofac.  <a href="https://github.com/autofac/Autofac" rel="nofollow noreferrer">https://github.com/autofac/Autofac</a> It is really fast and pretty good.  Here is a link with comparisons (made after Ninject fixed a memory leak issue).</p>\n\n<p><a href="http://www.codinginstinct.com/2008/05/ioc-container-benchmark-rerevisted.html" rel="nofollow noreferrer">http://www.codinginstinct.com/2008/05/ioc-container-benchmark-rerevisted.html</a></p>\n'}, {'answer_id': 21527, 'author': 'Rob Bazinet', 'author_id': 2305, 'author_profile': 'https://Stackoverflow.com/users/2305', 'pm_score': 2, 'selected': False, 'text': '<p>I think a good place to start is with Ninject, it is new and has taken into account alot of fine tuning and is really fast.  Nate, the developer, really has a great site and great support.</p>\n'}, {'answer_id': 21532, 'author': 'Julio César', 'author_id': 2148, 'author_profile': 'https://Stackoverflow.com/users/2148', 'pm_score': 2, 'selected': False, 'text': "<p>I can recommend Ninject. It's incredibly fast and easy to use but only if you don't need XML configuration, else you should use Windsor.</p>\n"}, {'answer_id': 70767, 'author': 'Chris Canal', 'author_id': 5802, 'author_profile': 'https://Stackoverflow.com/users/5802', 'pm_score': 3, 'selected': False, 'text': '<p>I\'m a huge fan of Castle.  I love the facilities it also provides beyond the IoC Container story.  It really simplfies using NHibernate, logging, AOP, etc.  I also use <a href="http://www.ayende.com/Blog/archive/7268.aspx" rel="noreferrer">Binsor</a> for configuration with Boo and have really fallen in love with Boo as a language because of it.</p>\n'}, {'answer_id': 145892, 'author': 'David Robbins', 'author_id': 19799, 'author_profile': 'https://Stackoverflow.com/users/19799', 'pm_score': 2, 'selected': False, 'text': '<p>Spring.Net is quite solid, but the documentation took some time to wade through.  Autofac is good, and while .Net 2.0 is supported, you need VS 2008 to compile it, or else use the command line to build your app. </p>\n'}, {'answer_id': 227012, 'author': 'Glenn Block', 'author_id': 18419, 'author_profile': 'https://Stackoverflow.com/users/18419', 'pm_score': 6, 'selected': False, 'text': "<p>It depends on what you are looking for, as they each have their pros and cons. </p>\n\n<ol>\n<li><strong><code>Spring.NET</code></strong> is the most mature as it comes out of Spring from the Java world. Spring has a very rich set of framework libraries that extend it to support Web, Windows, etc.</li>\n<li><strong><code>Castle Windsor</code></strong> is one of the most widely used in the .NET platform and has the largest ecosystem, is highly configurable / extensible, has custom lifetime management, AOP support, has inherent NHibernate support and is an all around awesome container. Windsor is part of an entire stack which includes Monorail, Active Record, etc. NHibernate itself builds on top of Windsor.</li>\n<li><strong><code>Structure Map</code></strong> has very rich and fine grained configuration through an internal DSL.</li>\n<li><strong><code>Autofac</code></strong> is an IoC container of the new age with all of it's inherent functional programming support. It also takes a different approach on managing lifetime than the others. Autofac is still very new, but it pushes the bar on what is possible with IoC.</li>\n<li><strong><code>Ninject</code></strong> I have heard is more bare bones with a less is more approach (heard not experienced).</li>\n<li>The biggest discriminator of <strong><code>Unity</code></strong> is: it's from and supported by Microsoft (p&amp;p). Unity has very good performance, and great documentation. It is also highly configurable. It doesn't have all the bells and whistles of say Castle / Structure Map.</li>\n</ol>\n\n<p>So in summary, it really depends on what is important to you. I would agree with others on going and evaluating and seeing which one fits. The nice thing is you have a nice selection of donuts rather than just having to have a jelly one.</p>\n"}, {'answer_id': 2012597, 'author': 'Steven', 'author_id': 244658, 'author_profile': 'https://Stackoverflow.com/users/244658', 'pm_score': 4, 'selected': False, 'text': '<p>I use <a href="https://simpleinjector.org/" rel="noreferrer">Simple Injector</a>:</p>\n\n<blockquote>\n  <p>Simple Injector is an easy, flexible and fast dependency injection library that uses best practice to guide your solutions toward the pit of success.</p>\n</blockquote>\n'}, {'answer_id': 5395479, 'author': 'outinsun', 'author_id': 671699, 'author_profile': 'https://Stackoverflow.com/users/671699', 'pm_score': 3, 'selected': False, 'text': '<p>I spent the better part of a day struggling without success to get the simplest Spring.NET example working. Could never figure out how to get it to find my assembly from the XML file. In about 2 hours, on the other hand, I was able to get Ninject working, including testing integration with both NUnit and MSTest.</p>\n'}]
['https://Stackoverflow.com/questions/21288', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2011/']