Trying to load configuration from Installer results in duplicate registrations
See original GitHub issueThis 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
internal class CastleContainer
{
static CastleContainer()
{
var path = System.AppDomain.CurrentDomain.BaseDirectory+"Windsor.config";
Current = new WindsorContainer(new XmlInterpreter(path));
}
public static IWindsorContainer Current { get; internal set; }
}
public class DatabaseInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
var source = new InMemoryResource();
////XmlInterpreter xi = new XmlInterpreter(source);
////xi.ProcessResource(xi.Source, store, container.Kernel);
//var kernel = container.Kernel;
//IResourceSubSystem resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
//resourceSubSystem.RegisterResourceFactory(new DatabaseResourceFactory());
container.Install(Configuration.FromXml(source));
}
internal class DatabaseResourceFactory : IResourceFactory
{
public bool Accept(CustomUri uri)
{
return "db".Equals(uri.Scheme);
}
public IResource Create(CustomUri uri)
{
return this.Create(uri, null);
}
public IResource Create(CustomUri uri, string basePath)
{
return new InMemoryResource();
}
}
public class InMemoryResource : IResource
{
public string FileBasePath
{
get
{
throw new NotImplementedException();
}
}
public IResource CreateRelative(string relativePath)
{
throw new NotImplementedException();
}
public void Dispose()
{
}
public TextReader GetStreamReader()
{
var config = @"<configuration> <components> <component id=""ConfigRepository"" service=""SimpleService.IMyService,SimpleService"" type=""SimpleService.MyService2,SimpleService"" > <parameters> <innerRepositoryKey>ConfigRepository.nh</innerRepositoryKey> </parameters> </component> </components></configuration> ";
return (new StringReader(config));
}
public TextReader GetStreamReader(Encoding encoding)
{
return GetStreamReader();
}
}
}
<configuration>
<installers>
<install assembly="WindsorSandbox"/>
</installers>
</configuration>
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
keras AssertionError: Duplicate registrations for type ' ...
Same problem : I completely uninstalled the libraries (nightly...), and reinstalled the latest stable version (pip3 install tensorflow) I'm ...
Read more >Known Issue and Workaround: Duplicate Records When ...
This workaround requires scripting and additional configuration steps but it might be appropriate if you must install software as soon as ...
Read more >Duplicate name registration error in InfoSphere DataStage ...
In order to restore the parallel engine in MPP configuration, using PXEngine/install/copy-orchdist is recommended instead of Copy (cp) command.
Read more >Service definition duplication by configuration files import
Hi all, I'm trying to import an existing configuration into a new installation of Nagios XI (this is a test environment with a...
Read more >Error Message: The configuration has not yet loaded. If this ...
Log in to the BIG-IP command line. Attempt to manually load the configuration by entering the following command: tmsh load sys config. If...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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
PartialConfigurationStore
of the parentDatabaseInstaller
and so gets set up twice.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
InMemoryResource
class, there isCastle.Core.Resource.StaticContentResource
.Please join the discussion on https://github.com/castleproject/Windsor/issues/338 I am proposing we deprecate XML configs. Closing this for now.