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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:48:49+00:00 2026-05-13T19:48:49+00:00

I am using the MvcContrib library with Castle Windsor and I am having a

  • 0

I am using the MvcContrib library with Castle Windsor and I am having a problem
with setting a parameter when I register a component.

I have the following interfaces for classes that wrap a DataContext. I want
to be able to specify which DataContext to use for different services because
I am connecting to several databases to retrieve data.

public interface IDataContext
{
    DataContext Context { get; }
}

public interface IReportingDC : IDataContext
{
}

public class Repository<T> : IRepository<T> where T : class
{

public IDataContext DC { get; set; }

  public Repository(IDataContext dataContext)
  {
    DC = dataContext;
  }
}

Here are the registration lines from my global.asax.cs.

container.AddComponentLifeStyle<IDataContext, MainDataContext>(Castle.Core.LifestyleType.PerWebRequest);

container.AddComponentLifeStyle<IReportingDC, ReportingDC>(Castle.Core.LifestyleType.PerWebRequest);

container.Register(Component.For<IRepository<ReportingTotals>>()
.ImplementedBy<Repository<ReportingTotals>>()
.Parameters(Parameter.ForKey("dataContext").Eq("IReportingDC"))
.LifeStyle.PerWebRequest
);

When I try and load the page I get the following error.

“Key invalid for parameter dataContext. Thus the kernel was unable to
override the service dependency”

  • 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-13T19:48:50+00:00Added an answer on May 13, 2026 at 7:48 pm

    Name your component and use ServiceOverrides instead of Parameters:

    Component.For<IReportingDC>()
             .ImplementedBy<ReportingDC>()
             .Named("IReporting")
             .LifeStyle.PerWebRequest
    

    and

    Component.For<IRepository<ReportingTotals>>()
             .ImplementedBy<Repository<ReportingTotals>>()
             .ServiceOverrides(ServiceOverride.ForKey("dataContext").Eq("IReporting"))
    

    See the fluent API docs for reference.

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

Sidebar

Related Questions

I have the following partial view code @model IEnumerable<PDoc.Web.Models.UserDocModel> @using MvcContrib.UI.Grid; @using MvcContrib.UI.Pager; @using
Using online interfaces to a version control system is a nice way to have
I have a simple controller test using MvcContrib's test helpers: var controller = new
I'm working in ASP.NET MVC 1.0 using MvcContrib FluentHtml version 1.0. The following code
I have a big .net mvc 2 project where we are using MvcContrib Portable
I have an issue with testing routes using the MVCContrib Fluent route testing. The
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I am using mvccontrib grid in asp.net mvc(C#) application. How can i apply css
I'd like for my column header to also be footers using MVCContrib grid. How
I am using MVC 2 with Areas. To test routing, I am using MvcContrib.

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.