New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to load configuration from Installer results in duplicate registrations #95
Comments
@richardspence this looks like an unsupported use case. From a quick look at the code it looks like the configuration your installer is "installing" gets loaded into the I probably wouldn't recommend loading an installer inside another installer. Do you want to describe what you are trying to do, as there is likely a better way. FYI, no need to make your own |
Thanks @jonorossi, I was able to get this to work by using the default constructor. So there appears to be a bug when using the XmlInterpreter constructor new WindsorContainer().Install(Configuration.FromXmlFile(....)); //works when this
new WindsorContainer(new XmlInterpreter(...)); //does not Although this fixed my above issue it didn't really help me that much. I was planning on registering a new resource factory within the new installer, but doing so doesn't allow you to use the custom uris within the parent (even if declared after the installers) since it looks as tho installers aren't erxecuted until the xml file is parsed. So I'll prob just change my approach here. Ultimately I wanted to drive all Windsor config and subsequent installers from a central config file. I've done the same sort of thing with Unity IoC with configuration and extensions. |
Without debugging the code to ensure this is the problem, but it appears that the WindsorContainer has a flaw in the ctor chainging that results in RunInstaller() being called twice for most ctors. Removing the calls to RunInstaller except for the most compex ctor might do the trick. |
All the constructors look good to me. This is the stack for your example, public WindsorContainer(IConfigurationInterpreter interpreter)
: this()
{
...
RunInstaller();
}
public WindsorContainer()
: this(new DefaultKernel(), new DefaultComponentInstaller())
public WindsorContainer(IKernel kernel, IComponentsInstaller installer)
: this(AppDomain.CurrentDomain.FriendlyName + CastleUnicode + ++instanceCount, kernel, installer)
public WindsorContainer(String name, IKernel kernel, IComponentsInstaller installer) If you weren't aware container.Install(Configuration.FromXmlFile(path));
container.Install(new ConfigurationInstaller(new XmlInterpreter(path))); Actually debugging the code it is similar to what I mentioned in my last comment. That constructor uses
To fix this I think we'd need to create a |
@richardspence lets use this issue for the defect you found, however...
I'm not sure what you actually mean. If you want to explore it further jump on the users mailing list or open another issue. Thanks. |
Please join the discussion on #338 I am proposing we deprecate XML configs. Closing this for now. |
This is my first time playing with Castle, so maybe I'm doing something idiotic:
I'm creating a new Container that loads an xml file. That xml file loads a custom installer. The custom installer will feed additional xml files. Doing this components fed at the custom installer level are somehow registered twice causing a typeinitializer exception.
Here is some of the code
The text was updated successfully, but these errors were encountered: