sorry if this was asked before I tried to do some google-ing and didn't find any matches, so here goes ....
I have a Castle Windsor container that I add to my components using the following method (where the container is an instance of IWindsorContainer ) ...
container.Register(AllTypes.FromAssemblyNamed("App.Infrastructure") .Where(x => !x.IsAbstract && !x.IsInterface) .WithService.DefaultInterface()
This works fine, however I want to register another DLL in the same way to resolve dependencies on this ...
container.Register(AllTypes.FromAssemblyNamed("App.Client.Infrastructure") .Where(x => !x.IsAbstract && !x.IsInterface) .WithService.DefaultInterface()
Now, anyway, I can get Windsor to notify me if the same interface resolution is added, i.e. there is only one performer per interface (take the first if more than one exists).
Hope I explained quite well. I am using Castle Windsor version: 2.5.1.0 and updating / changing the version is not really options.
Update:
I solved this by deleting duplicate registrations after registering them. After registration is complete, I get a loop below ...
var registeredServices = new Dictionary<Type, string>(); foreach (var node in container.Kernel.GraphNodes) { var cmp = ((Castle.Core.ComponentModel)node); Type t = cmp.Service; if (registeredServices.ContainsKey(t)) container.Kernel.RemoveComponent(cmp.Name); else registeredServices.Add(t, cmp.Implementation.FullName); }
source share