Which Dependency Injection Tool Should I Use? [closed]

Having recently spiked the use of 6 of these (Windsor, Unity, Spring.Net, Autofac, Ninject, StructureMap) I can offer a quick summary of each, our selection criteria and our final choice. Note: we did not look at PicoContainer.Net as one of our team considered the .Net port to be quite poor from the Java version. We … Read more

Design – Where should objects be registered when using Windsor [closed]

In general, all components in an application should be composed as late as possible, because that ensures maximum modularity, and that modules are as loosely coupled as possible. In practice, this means that you should configure the container at the root of your application. In a desktop app, that would be in the Main method … Read more

Comparing Castle Windsor, Unity and StructureMap

See here and here for a pretty thorough technical comparison of several IoC containers, although somewhat outdated by now (they’re from before Windsor 2.0) However, I don’t think there are really any vital features that Windsor offers and other containers don’t. Windsor, StructureMap, Spring.NET have all been around for several years and have been used … Read more

Why not use an IoC container to resolve dependencies for entities/business objects?

The first question is the most difficult to answer. Is it bad practice to have Entities depend on outside classes? It’s certainly not the most common thing to do. If, for example, you inject a Repository into your Entities you effectively have an implementation of the Active Record pattern. Some people like this pattern for … Read more

Ioc/DI – Why do I have to reference all layers/assemblies in application’s entry point?

If I wasn’t using a DI container, I wouldn’t have to reference EntityFramework library in my MVC3 app, only my business layer which would reference my DAL/Repo layer. Yes, that’s exactly the situation DI works so hard to avoid 🙂 With tightly coupled code, each library may only have a few references, but these again … Read more

What is Castle Windsor, and why should I care?

Castle Windsor is an inversion of control tool. There are others like it. It can give you objects with pre-built and pre-wired dependencies right in there. An entire object graph created via reflection and configuration rather than the “new” operator. Start here: http://tech.groups.yahoo.com/group/altdotnet/message/10434 Imagine you have an email sending class. EmailSender. Imagine you have another … Read more