Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 101671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:48:59+00:00 2026-05-11T00:48:59+00:00

What’s pros and cons of using Enterprise Library Unity vs other IoC containers (Windsor,

  • 0

What’s pros and cons of using Enterprise Library Unity vs other IoC containers (Windsor, Spring.Net, Autofac ..)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:48:59+00:00Added an answer on May 11, 2026 at 12:48 am

    I am preparing a presentation for a usergroup. As such I just went through a bunch of them. Namely: AutoFac, MEF, Ninject, Spring.Net, StructureMap, Unity, and Windsor.

    I wanted to show off the 90% case (constructor injection, which is mainly what people use an IOC for anyway). You can check out the solution here (VS2008)

    As such, there are a few key differences:

    • Initialization
    • Object retrieval

    Each of them have other features as well (some have AOP, and better gizmos, but generally all I want an IOC to do is create and retrieve objects for me)

    Note: the differences between the different libraries object retrieval can be negated by using the CommonServiceLocator: http://www.codeplex.com/CommonServiceLocator

    That leaves us with initialization, which is done in two ways: via code or via XML configuration (app.config/web.config/custom.config). Some support both, some support only one. I should note: some use attributes to help the IoC along.

    So here is my assessment of the differences:

    Ninject

    Code initialization only (with attributes). I hope you like lambdas. Initialization code looks like this:

     IKernel kernel = new StandardKernel(                 new InlineModule(                     x => x.Bind<ICustomerRepository>().To<CustomerRepository>(),                     x => x.Bind<ICustomerService>().To<CustomerService>(),                     x => x.Bind<Form1>().ToSelf()                     )); 

    StructureMap

    Initialization code or XML or Attributes. v2.5 is also very lambda’y. All in all, this is one of my favorites. Some very interesting ideas around how StructureMap uses Attributes.

    ObjectFactory.Initialize(x => {     x.UseDefaultStructureMapConfigFile = false;     x.ForRequestedType<ICustomerRepository>()         .TheDefaultIsConcreteType<CustomerRepository>()         .CacheBy(InstanceScope.Singleton);      x.ForRequestedType<ICustomerService>()         .TheDefaultIsConcreteType<CustomerService>()         .CacheBy(InstanceScope.Singleton);      x.ForConcreteType<Form1>();  }); 

    Unity

    Initialization code and XML. Nice library, but XML configuration is a pain in the butt. Great library for Microsoft or the highway shops. Code initialization is easy:

     container.RegisterType<ICustomerRepository, CustomerRepository>()           .RegisterType<ICustomerService, CustomerService>(); 

    Spring.NET

    XML only as near as I can tell. But for functionality Spring.Net does everything under the sun that an IoC can do. But because the only way to unitize is through XML it is generally avoided by .net shops. Although, many .net/Java shop use Spring.Net because of the similarity between the .net version of Spring.Net and the Java Spring project.

    Note: Configuration in the code is now possible with the introduction of Spring.NET CodeConfig.

    Windsor

    XML and code. Like Spring.Net, Windsor will do anything you could want it to do. Windsor is probably one of the most popular IoC containers around.

    IWindsorContainer container = new WindsorContainer(); container.AddComponentWithLifestyle<ICustomerRepository, CustomerRepository>('CustomerRepository', LifestyleType.Singleton); container.AddComponentWithLifestyle<ICustomerService, CustomerService>('CustomerService',LifestyleType.Singleton); container.AddComponent<Form1>('Form1'); 

    Autofac

    Can mix both XML and code (with v1.2). Nice simple IoC library. Seems to do the basics with not much fuss. Supports nested containers with local scoping of components and a well-defined life-time management.

    Here is how you initialize it:

    var builder = new ContainerBuilder(); builder.Register<CustomerRepository>()         .As<ICustomerRepository>()         .ContainerScoped(); builder.Register<CustomerService>()         .As<ICustomerService>()         .ContainerScoped(); builder.Register<Form1>(); 

    If I had to choose today: I would probably go with StructureMap. It has the best support for C# 3.0 language features, and the most flexibility in initialization.

    Note: Chris Brandsma turned his original answer into a blog post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Message-Ids don't have anything to do with web pages or… May 11, 2026 at 8:53 am
  • added an answer Why not use your original method but also record where/what… May 11, 2026 at 8:53 am
  • added an answer This works: private DataTable MakeStudentsTable() { DataTable students = new… May 11, 2026 at 8:53 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.