Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:42:41+00:00 2026-05-25T16:42:41+00:00

I’m trying to overwrite a component registration (done via xml) with another one (in

  • 0

I’m trying to overwrite a component registration (done via xml) with another one (in another xml, loaded via code using container.Install(Configuration.FromXmlFile("...")) that has the same component id, but i receive an error saying:

“Component COMP_ID could not be registered. There is already a component with that name.
Did you want to modify the existing component instead? If not, make sure you specify
a unique name.”

The thing is, i in fact actually would like to modify the existing component, to be able to define basic wiring in a basic castle.xml file and then overwrite it, in another custom.xml file, loaded after the basic one.

I’m trying to use the same component id because a tought it would have rewritten the previous registration.

The reality is that i would like to change wich implementation is used to respond to a service, the component id is just a try that i’ve done. Since Castle has a policy of first-registration-wins, it would be enough for example to switch to a last-registration-wins, for example.

Concrete example

Let’s use the example of an ILogger interface.

The basic castle.xml (loaded always) would be like this:

<component id="logger" service="ILogger" type="NullLogger" ></component>

The castle.dev.xml file (loaded only in the dev ambient, after the default one) would look like this:

<component id="logger" service="ILogger" type="AspNetTraceLogger" ></component>

The castle.prod.xml file (loaded only in production ambient, after the default one, instead of the dev one) would look like this:

<component id="logger" service="ILogger" type="SqlServerLogger" ></component>

Now: for each of these configurations, I would like to say “respond to ILogger requests with this impl”, so I need to have only one of them to respond to requests for ILogger at each time.

Anyone have any idea?

update

I’ll add: as of now i’m using a, shall we say, “reverse overwriting” technique, where i load the overwriting files “first”, before the corresponding “default” ones. In this way, since the policy is first-wins, i can declare them as overwrites, even though internally they are declared before. The problem with this approach is when i have an interface that i know will be implemented more than once (say, IWhateverListener): in this case i cannot remove the other ones already registered, and cannot use the first-wins solution because later on i’ll use a ResolveAll() and the “default ones” will be used too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:42:42+00:00Added an answer on May 25, 2026 at 4:42 pm

    Don’t try to register several components with the same ID, or try to hack around it.

    If you must use XML, take a look at defines and ifs.

    Otherwise just use different installers, one for each environment, and at application startup register the one you want

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.