I can't seem to register my Castle Windsor objects by convention and I'm really at a loss. The situation is I have two projects, Website (a really basic web forms project) and BusinessObjects (a class library). I'm attempting to use IoC to be able to keep all of my business object implementations internal, and only deal with the interfaces in the Website project.
The best way that I've found to accomplish this is to use installers. So, in my Global.asax.cs I have this:
private IWindsorContainer _container;
public override void Init()
{
base.Init();
InitializeIoC();
Global.WindsorContainer = _container;
}
private void InitializeIoC()
{
_container = new WindsorContainer();
_container.Install(new BusinessObjectsInstaller());
}
public static IWindsorContainer WindsorContainer { get; private set; }
Which seems to work just fine, and to pull an object out of the container, I'm just using a very simple:
var thingey = Global.WindsorContainer.Resolve<IThingey>();
And then in my BusinessObjects project, I have this:
public class BusinessObjectsInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<IThingey>().ImplementedBy<Thingey>());
}
}
Now, at this point, everything is working as I expect it to. It's not elegant or anything, but I'm still trying to get a handle on this. So the big thing I'm trying to accomplish at this point is to wire these objects up in a more useful way, which lead me to replacing the above component registration with this:
container.Register(Classes
.FromThisAssembly()
.BasedOn<IThingey>()
.LifestyleTransient()
);
Which I absolutely cannot get to work. All I get is
No component for supporting the service
BusinessObjects.Contracts.IThingey was found
Ultimately the class registration will be changed to another interface that the others inherit from, but one step at a time.
Any help figuring what's going on / what I'm doing wrong would be greatly appreciated.