2
    container.Register(
        AllTypes.Pick().FromAssembly(typeof (UserRepository).Assembly)
            .WithService.FirstInterface());

Currently the code above will work fine if the interface are also in the same assembly but it will blow up if IUserRepository is from a different assembly.

Is auto registration from two different assemblies possible? Am I missing something here?

firefly
  • 285
  • 3
  • 12
  • Check out this site to see how to do it if your base class inherit from a different interface http://blog.theagileworkshop.com/2009/06/09/extension-methods-we-use-for-auto-registration-in-castle-windsor/ – firefly Jan 13 '10 at 19:56

1 Answers1

5

Yes, it's possible to define auto-registration where the interface is defined in a different assembly. We do it, although we use a slightly different syntax:

container.Register(AllTypes
    .FromAssemblyContaining<ConfigurationService>()
    .Where(t => t.Name.EndsWith("Service", StringComparison.Ordinal))
    .WithService
    .FirstInterface()
    .Configure(reg => reg.LifeStyle.PerWebRequest));

I can't say if the different API usage makes a difference, but I would assume that it doesn't. Rather, I would guess that the cause of the error you experience is that perhaps the assembly containing the interface isn't available.

Check if Fusion can load the type from that application at all.

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
  • 1
    You are right it's possible. My problem was that UserRepository inherit from a base class that inherit from another interface. So the interface from the base class got pick up instead. Though thanks to you I don't have to end up chasing a ghost tail. I've also edit the question to include the solution – firefly Jan 13 '10 at 19:55