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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:09:13+00:00 2026-05-25T15:09:13+00:00

So I went through the asp.net mvc tutorial for castle windsor, and my registrations

  • 0

So I went through the asp.net mvc tutorial for castle windsor, and my registrations look like:

    private static IWindsorContainer _container = new WindsorContainer();
    private static void BootstrapContainer()
    {
        _container = new WindsorContainer()
            .Install(FromAssembly.This());
        var controllerFactory = new WindsorControllerFactory(_container.Kernel);
        ControllerBuilder.Current.SetControllerFactory(controllerFactory);
    }
    protected void Application_End()
    {
        _container.Dispose();
    }

So in my HomeController I have this:

public class HomeController : Controller
{
    private IUserService _userService;

    public HomeController(IUserService userService)
    {
        this._userService = userService;
    }
}

How would I go about wiring this controller up to setup the IUserService?

Update
In case in matters how I need to wire things up, my vs.net projects are:

web, interfaces, entities, data (nhibernate), services
  • 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-25T15:09:14+00:00Added an answer on May 25, 2026 at 3:09 pm

    The implementation of WindsorControllerFactory should look like this from the doco http://docs.castleproject.org/Windsor.Windsor-tutorial-part-two-plugging-Windsor-in.ashx?HL=ikernel.

    public class WindsorControllerFactory : DefaultControllerFactory 
    { 
       private readonly IKernel kernel; 
    
       public WindsorControllerFactory(IKernel kernel) 
       { 
           this.kernel = kernel; 
       } 
    
       public override void ReleaseController(IController controller) 
       { 
           kernel.ReleaseComponent(controller); 
       } 
    
       protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) 
       { 
           if (controllerType == null) 
           { 
               // Throw exception. Can't resolve null type.
           }
    
           return (IController)kernel.Resolve(controllerType);
       } 
    }
    

    UPDATED

    Each interface that needs to be resolved by dependancy injection need to be registered.

    This can be done by calling the .Register method on the container.

    container.Register(Component.For<IUserService>().ImplementedBy<UserService>().LifeStyle.Transient);
    

    More info here: http://docs.castleproject.org/Windsor.Registering-components-one-by-one.ashx

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

Sidebar

Related Questions

I am learning asp.net mvc and went through a great tutorial that demonstrated it.
I´m working with ASP.NET MVC and went through some code and the syntax below
I've been working through the book Pro ASP.NET MVC 2 Framework by Steven Sanderson.
am planning to implement Castle windsor in WCF layer, which is an ASP.Net project.
I just went through some MVC tutorials after checking this site out for a
I recently started learning Emacs . I went through the tutorial, read some introductory
By ASP.NET MVC plugin architecture, Plug-in architecture for ASP.NET MVC I have separated DLL(plugin)
i am just getting started with ASP.NET MVC and i'm using NHibernate for my
Does installing ASP.NET MVC require a server reboot? I've set up quite a few
In ASP.NET MVC you can return a redirect ActionResult quite easily: return RedirectToAction("Index"); or

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.