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 7766867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:31:55+00:00 2026-06-01T15:31:55+00:00

We have a solution whith multiple projects representing the layers of our application. e.g.

  • 0

We have a solution whith multiple projects representing the layers of our application.
e.g.

Domain

Data

Logic

WebUI

Our Castle Windsor container is referenced from our web layer and we then cascade these dependancies up through our layers. For example…

// In Domain
public interface IFooRepository
{
    void DoSomething();
} 

// In Data
public class FooRepository : IFooRepository
{
    public void DoSomething()
    {
        // Something is done
    }
}

// In Logic
public class MyThingManager
{
    private readonly IFooRepository fooRepository;

    public MyThingManager(IFooRepository fooRepository)
    {
        this.fooRepository = fooRepository;
    }

    public void AMethod()
    {
        this.fooRepository.DoSomething();
    }

}

// In Web
// in some controller....
var newManager = new MyThingManager(WindsorContainer.Resolve<IFooRepository>());
newManager.DoSomething();

and this works nicely until our managers have lots of members that have their own dependancies. When this happens we end up resolveing both the managers dependancies and their dependancies depandancies and cascading them up from the web layer. This results is some rather large constructors.

Is there a more elegant way of, for example having the inner components of a manager resolve it’s own dependancies without having access to the container?

Bear in mind that ONLY the web layer has access to the container (to prevent a circular project dependancy), so only the web layer can activly WindsorContainer.Resolve() the logic layer can’t so the only way to cascade a dependancy without the containers assistance was to resolve it in the web layer then pass it up the chain using it’s interface.

  • 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-06-01T15:31:56+00:00Added an answer on June 1, 2026 at 3:31 pm

    Short answer is that whenever you see .Resolve<T> you are probably doing it wrong. As @Steven mentioned, you want to use the inbuilt features of Windsor to provide you with constructor injection (and/or property injection). This means that WindsorContainer needs to know the object that is at the root of your object graph.

    In your case, you would walk up the tree of objects (from MyThingyManager) until you get to the root object. For example, in an ASP.NET MVC app this would be the controller that contains the action being called. For the MVC3 case, you would use a DependencyResolver to kick off the injection of all dependencies.

    Further, what I have found useful with Windsor in the past is to have a different Installer per component (assembly). And then register these installers at the base of the process that is hosting the application.

    So in each component you would have an installer like:

    public class Installer : IWindsorInstaller
    {
            public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
            {
                container.Register(
                    Component.For<IMyThingManager>().ImplementedBy<MyThingManager>(),
                    Component.For<IFooRepository>().ImplementedBy<FooRepository>()
                    );
            }
    }
    

    And then in the Global.asax.cs Application_Start you would have something like:

    var container = new WindsorContainer();
    container.Install(FromAssembly.This());
    container.Install(FromAssembly.Containing(typeof(ComponentThatContains.MyThingManager.Installer)));
    

    This gives you a way to manage all dependencies down the entire object graph and resolve through constructor injection.
    Hope this helps.

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

Sidebar

Related Questions

strange 1 here.. have a solution with multiple projects in (mvc2 application, class library
I have a solution which has multiple output projects (a website, and admin tool,
I have a visual studio 2008 solution with multiple c# library projects, a Web
I have a huge solution with multiple projects. Sometime I need to navigate to
I'm working on a solution with multiple projects (class libraries, interop, web application, etc)
I have a C++ solution in VS2008 with multiple projects. This solution contains files
I have a solution made up of multiple projects which have various dependencies on
I have a solution with multiple projects and one of these projects is my
I have vs2003 c# solution with multiple projects. It seems like project1 in sln
I have a solution with multiple F# projects. I can easily reference between projects

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.