views:

115

answers:

3

Possible Duplicate:
Which C#/.NET Dependency Injection frameworks are worth looking into?

Yes I know this question has been asked many times, but the various frameworks keep evolving, so I would like a fresh answer on the subject.

A few thoughts about the framework, they are not necessary black or white, but rather my preferences.

Things I like:

  • Convention based registrations
  • Constructor injection
  • Can also target Silverlight
  • Small footprint
  • One assembly
  • Fast

Thing I don't like:

Things I don't think about:

  • Linq
  • Opensource
+1  A: 

Sounds like you might want to try NInject.

It has a definite focus on being easy to use with little configuration overhead (no bulky XML config files, etc). It even comes with a nice, shiny, fluent interface to make things understandable.

Justin Niessner
I've used Ninject on several projects and I really like it. It fulfills all of your requirements (except I don't know about Silverlight).
John Bledsoe
+1  A: 

autofac

Ninject

Gerrie Schenck
+1 for autofac.
kenny
A: 

When you're not familiar yet with any of the big DI frameworks, you might consider the very easy SimpleServiceLocator (shameless plug). Let's compare it to your check list:

  • Constructor injection, check!
  • Can also target Silverlight, check!
  • Small footprint, check!
  • One assembly, nope 2. It needs the Common Service Locator.
  • Fast, double check!
  • No Xml, check! Only code based configuration is supported.
  • No Custom attributes, check! It is completely attribute free.
  • No Service locator pattern, check. Despite its name, you can do DI with it (just look at the examples on the site).
  • Open source, check! MIT License.

The idea behind the Simple Service Locator is:

to provide .NET application developers with a inversion of control (IoC) framework that is truly easy to use, while allowing developers to replace it with a more feature-rich IoC framework when needed.

The Simple Service Locator is an implementation of the Common Service Locator library. The Common Service Locator is a shared interface for inversion of control and dependency injection which application and framework developers can reference.

Steven