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

  • Home
  • SEARCH
  • 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 346073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:08:35+00:00 2026-05-12T11:08:35+00:00

Seems like a standard approach for an ioc when given a scenario like (C#

  • 0

Seems like a standard approach for an ioc when given a scenario like (C# windsor):

container.AddComponent<ILogger, HttpLogger>();
container.AddComponent<ILogger, SmtpLogger>();

var logger = container.Resolve<ILogger>();

Would be that when resolving the component, the first registered ILogger (HttpLogger in this case) is the only candidate for resolution, the ioc will then find the ‘fattest’ constructor it can where it believes it can resolve all the dependencies.

However, it may well be the ioc cannot resolve the dependencies for the first logger, and will thusly return with a resolution issue, it could well be the case that the SmtpLogger COULD have been resolved if the ioc tried it.

So what is the reasoning for only using the first registered service as the candidate? it seems that the uncertainty of which type you will get is an argument, but then the ioc is being left in charge of which constructor that it uses anyway.

So why not pick from all the constructors of all applicable types, and start trying to resolve from the fattest constructors down (agnostic of the real type)?

This may have a really obvious answer but honestly I don’t know it.

Thanks in advance,
Stephen.

  • 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. Editorial Team
    Editorial Team
    2026-05-12T11:08:36+00:00Added an answer on May 12, 2026 at 11:08 am

    The reason for this is its effect on implementation complexity.

    When this kind of behaviour is implemented, it turns out to work recursively, e.g. figuring out whether the dependencies of one of the loggers can be satisfied will require a walk down all of its dependencies and so on.

    To do this efficiently is hard, and adds a lot of complexity to the container and to the debugging experience.

    MEF, while not strictly an IoC container, does do this in a way similar to what you’ve suggested – it is part of the Stable Composition behaviour, something we refer to as ‘rejection’.

    http://blogs.msdn.com/nblumhardt/archive/2009/07/17/light-up-or-mef-optional-exports.aspx

    In highly-dynamic plug-in scenarios, rejection is extremely useful. In the scenarios Windsor, Autofac etc are targeting, the added effort doesn’t pay off so much.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer NSFileManager *fm = [NSFileManager defaultManager]; NSString *directory = [[self documentsDirectory]… May 13, 2026 at 4:03 pm
  • Editorial Team
    Editorial Team added an answer As noted, if you are going do this with straight… May 13, 2026 at 4:03 pm
  • Editorial Team
    Editorial Team added an answer UPDATE: I removed my previous answer because it is no… May 13, 2026 at 4:03 pm

Related Questions

I will likely be responsible for porting a vb6 application to c#. This application
I'm considering writing my own tool for tracking visitors/sales as Google Analytics and others
I have a 3-tier .NET service app, which follows the standard approach: Frontend ->
This is a two part question. A dumb technical query and a broader query

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.