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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:44:57+00:00 2026-05-16T22:44:57+00:00

I have a reporting MVC application that uses Castle Windsor. On application start up

  • 0

I have a reporting MVC application that uses Castle Windsor.

On application start up (in global.asax) all of the types are registered and then each subsequent request to the application resolves the relevant report type and windsor automatically handles the dependencies.

I need to switch one of the dependant types for another depending on a parameter passed in on the request.

How can I achieve this?

I have registered a factory method with windsor to handle the resolution of the switchable types but as this is registered on application start how can I pass a parameter to the factory method when the parameter is only available on a later request?

If I try registering the factory for each request it works on the first request but then complains on all subsequent requests that the factory is already registered. Unregistering the factory after each request doesnt sound like the right thing to be doing.

  • 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-16T22:44:58+00:00Added an answer on May 16, 2026 at 10:44 pm

    When you need to resolve types at runtime, the normal solution is to inject a factory that can make the decision at the appropriate time:

    public class ReportFactory: IReportFactory {
        IReport CreateReport(bool useDefault) {
            if (useDefault) {
                return new DefaultReport();
            } else {
                return new UnusualReport();
            }
        }
    }
    

    Classes that previously required an IReport should demand an IReportFactory instead.

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

Sidebar

Related Questions

I have a Spring Web MVC application that I'd like to serve a large,
I realize that ASP.NET MVC has all the hype. I have my doubts that
I have a simple Spring MVC application that looks up some user details from
I am building an mvc app for reporting. I have a page that has
I'm using a logging module that can have reporting enabled/disabled at runtime. Calls generally
I have a user reporting that when they use the back button to return
We have some SQL server reporting services reports. I didn't write then but I
We have are relatively simple Reporting Services report that our users commonly export to
I have a report in SQL Server Reporting Services (SSRS) that I'd like to
I have some reports in SQL Server Reporting Services 2005 that I need to

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.