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

  • SEARCH
  • Home
  • 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 3316464
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:28:20+00:00 2026-05-17T22:28:20+00:00

The short question: Does Castle Windsor have something similar to Spring.Net’s Lookup Method Injection

  • 0

The short question:
Does Castle Windsor have something similar to Spring.Net’s “Lookup Method Injection” that can be configured from XML, which provides the ability to fetch transient instances from the container without the class being aware of the IoC container?

The long question:
I’m a long time Spring/Spring.Net user and I have been experimenting with Castle Windsor, by trying to port a project over to it. Spring.Net has a concept of “Lookup Method Injection” which (from the Spring docs)…

Lookup method injection is the ability of the container to override methods on container managed objects, to return the result of looking up another named object in the container. The lookup typically involves a prototype object as in the scenario described in the preceding section. The Spring framework implements this method injection by a dynamically generating a subclass overriding the method using the classes in the System.Reflection.Emit namespace.

What this means is, If I had the following…

public class SomeTransient
{
    // ... I have dependencies that need to be filled by IoC container
}

public class SomeClass
{
    public virtual void Work()
    {
        var o = CreateTransient();
    }

    public virtual SomeTransient CreateTransient() { }
}

I can instruct Spring to override the CreateTransient method, and have that method return a new container created transient instance (with it’s dependencies initialized) each time the method is called.
The unique part of this is, it doesn’t require direct links to the Spring Framework (eg. SomeClass doesn’t have to implement a specific interface).

Is there something similar in Castle Windsor to accomplish this via XML?

(I will eventually move away from XML config, but at the moment I’m just trying to get it running)

  • 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-17T22:28:21+00:00Added an answer on May 17, 2026 at 10:28 pm

    Castle has something better; Typed Factories.
    You can also inject even a delegate!
    http://stw.castleproject.org/Windsor.Typed-Factory-Facility-delegate-based-factories.ashx

    It is better because it does not depend on dynamically generation code, and it looks much more cleaner.

    It looks much more cleaner because the class doesn’t depend on someone overriding that method. It is impossible to test this class without subclassing.

    If you really want to do something like this, i would expect:

    public abstract class SomeClass
    {
      public abstract SomeTransient CreateTransient();
    }
    

    but… again it doesn’t feel right.

    Edit 2

    Unity 2 support these kind of delegate factories; you can read more here:
    http://www.truewill.net/myblog/index.php/2010/05/06/unity_2_0_combining_injectionfactory_and

    thanks to @eiximenis

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

Sidebar

Related Questions

Short question :) Does anyone have a method for creating a Inner glow effect
I have two short question regarding Azure Storage Tables. Is there something like an
I have one question about the short data type in Java. I know that
Short question: Is the parent of an entity group included in that entity group
Short question: I'm trying to make that in a given page (uses tabs) back
Short question, if this works (and it does): eval(new + generator.className + ( +
The short question is: if I hg rollback , how does Peter get my
Short question, why does Assert.AreEqual(1.0, double.NaN, 1.0) pass? Whereas Assert.AreEqual(1.0, double.NaN) fails. Is it
Short Question I have a 50dip by 40dip button in my Android XML layout.
Simple and short question but it seems that I can't find the answer anywhere.

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.