简体   繁体   中英

Castle Windsor Service binding assemblies

Warning: I'm really new to Windsor.

I have 1 solution that has multiple projects. I have a project that contains all our interfaces (named "Framework") and other ones that hold concrete implementations to those interfaces. I'm attempting to have Windsor bind these and resolve my interfaces like so:

One of the other projects is called "Orders" which has an Order class that implements IOrder which is defined in the frameworks project. There is a reference between the two projects and it does compile.

I have another project that has the actual windsor call that I've created a installer for:

public class CoreInstaller : IWindsorInstaller
  {
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.Register(
          AllTypes.FromAssemblyNamed("Framework"),
          AllTypes.FromAssemblyNamed("Orders")
        );
    }
  }

I instantiate the windsor container as such:

new WindsorContainer().Install(new CoreInstaller());

When I attempt to resolve IOrder , it fails with:

Castle.MicroKernel.ComponentNotFoundException: No component for supporting the service Framework.IOrder was found

I've also tried flipping the projects in the install function to load Orders first but I get the same error.

Any Windsor users out there that can help me?

You have effectively told Windsor to get all the types, but you haven't told it what to do with them yet. If you are not going to filter the types you want to register and what interface you want to register with, you need to add the Pick() method to your registration.

For example...

container.Register(
    Classes.FromAssemblyNamed("Framework").Pick(),
    Classes.FromAssemblyNamed("Orders").Pick()
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM