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 745523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:35:35+00:00 2026-05-14T09:35:35+00:00

How can I inject the value of an appSettings entry (from app.config or web.config)

  • 0

How can I inject the value of an appSettings entry (from app.config or web.config) into a service using the Windsor container? If I wanted to inject the value of a Windsor property into a service, I would do something like this:

<properties>
    <importantIntegerProperty>666</importantIntegerProperty>
</properties>
<component
    id="myComponent"
    service="MyApp.IService, MyApp"
    type="MyApp.Service, MyApp"
    >
    <parameters>
        <importantInteger>#{importantIntegerProperty}</importantInteger>
    </parameters>
</component>

However, what I’d really like to do is take the value represented by #{importantIntegerProperty} from an app settings variable which might be defined like this:

<appSettings>
    <add key="importantInteger" value="666"/>
</appSettings>

EDIT: To clarify; I realise that this is not natively possible with Windsor and the David Hayden article that sliderhouserules refers to is actually about his own (David Hayden’s) IoC container, not Windsor.

I’m surely not the first person to have this problem so what I’d like to know is how have other people solved this issue?

  • 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-14T09:35:35+00:00Added an answer on May 14, 2026 at 9:35 am

    I came up with a solution for this eventually based on hints from various sources on the web. The end result though involved pretty much copying three classes from Windsor verbatim and modifying them just a little bit. The end result is up on codeplex for your enjoyment.

    http://windsorappcfgprops.codeplex.com/

    I originally wrote this code quite some time ago so it’s based on Windsor 1.0.3 – yes, it took me that long to get around to publishing the result!

    The code allows you to have this in your app.config (or web.config, obviously):

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="theAnswer" value="42"/>
      </appSettings>
    </configuration>
    

    …and access it from your Windsor XML config file like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <castle>
      <components>
        <component
          id="answerProvider"
          service="Acme.IAnswerProvider, Acme"
          type="Acme.AnswerProvider, Acme"
          >
          <parameters>
            <theAnswer>#{AppSetting.theAnswer}</theAnswer>
          </parameters>
        </component>
      </components>
    </castle>
    

    There’s a working example in the solution.

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

Sidebar

Related Questions

Does anyone know if I can inject value from pages.xml into a Seam component?
When using Ninjects ConstructorArgument you can specify the exact value to inject to specific
I've got several components registered in my container and Windsor can inject them without
Is there any way we can inject new methods and properties into classes during
I'm looking for method to inject value into a <c:if test> . The code
How can I inject ALL parameters in a service? I know I can do:
I have a custom service and I want to inject the value of the
In Java 6, is it possible to inject some value into a ( @Target(ElementType.PARAMETER)
I like to inject DLLs to processes, because I can change certain values of
I wonder, if I can inject a list of (stateless) beans, that all implementing

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.