In my application, i use the following Install call:
 
container.Install(Configuration.FromAppConfig(), FromAssembly.This());



In the most preferable case, the app.config has an empty configuration 
block, with everything else being done by Installer classes.
However, one reason why I'd like the app.config in front is that I can 
override whatever the Installer decides...at least thats what I initially 
thought was possible. My use case would be to provide a small assembly 
containing one class containing a bugfix, and configuring it using XML to 
replace the component registered by the installers.

Trigger was this line from the documentation 
<http://docs.castleproject.org/Windsor.Registering-components-one-by-one.ashx#Register_more_components_for_the_same_service:_4>
:

> *In Windsor first one wins* 
> * In Castle, the default implementation for a service is the first 
> registered implementation.[...]*


Now I actually tried to do this; and was faced with a 
ComponentRegistrationException 
stating that the component is already present.

The component I tried to replace was registered without an explicit name 
(so it uses Type.FullName), but even when providing a Name the Exception is 
raised (obviously, since 
Castle.MicroKernel.SubSystems.Naming.DefaultNamingSubSystem 
tries Dictionary.Add and throws if something happens).

So, the installer basically does this:
 
container.Register(Component.For<ApplicationNamespace.IService>().
ImplementedBy<ApplicationNamespace.ComponentClass>());


Even specifying the usual suspects of IsFallback() or explicitly naming the 
services has the same result.

And the XML does this:
 
<component id="ApplicationNamespace.ComponentClass" service=
"ApplicationNamespace.IService" type="ReplacementNamespace.ComponentClass, 
ReplacementAssembly"/>



Surprisingly, I can actually do this both from within Code and within XML 
(registering the same service multiple times); but it seems I cannot mix 
those two.

Is there any built-in mechanism to support this scenario, or what would I 
have to do to support this on my own?

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to