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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:47:57+00:00 2026-05-25T20:47:57+00:00

I want to register controllers programatically in Global.asax.cs . with MvcContrib.Castle.WindsorControllerFactory private static IWindsorContainer

  • 0

I want to register controllers programatically in Global.asax.cs.
with MvcContrib.Castle.WindsorControllerFactory

private static IWindsorContainer _Container;

protected virtual void InitializeWindsor()
        {
            try
            {
                if (_Container == null)
                {
                    _Container = new WindsorContainer();
                    ControllerBuilder.Current.SetControllerFactory(new MvcContrib.Castle.WindsorControllerFactory(_Container));

                    RegisterActiveRecord();
                    RegisterRepositories();
                    RegisterServices();  
                    RegisterControllers();
                    RegisterComponents();
                }

I have done it by

 private void RegisterControllers()
        {
            try
            {
                _Container.Register(
                    AllTypes.Of<IController>()
                    .FromAssembly(typeof(HomeController).Assembly)
                    .Configure(c => c.LifeStyle.Transient)
                    );

It works fine for all controllers with default constructors.
But, I have a controller (LoginController) with parameterzied construtor.

public class LoginController : Controller
    {
        private IUser _User;

        public LoginController(IUser objUser)
        {
            _User = objUser;
        }

When I tried to view it in browser (http://localhost:2011/Login), it gives me following error.

**No parameterless constructor defined for this object**
Stack Trace: 
[MissingMethodException: No parameterless constructor defined for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.Activator.CreateInstance(Type type) +6
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +491

[InvalidOperationException: An error occurred when trying to create a controller of type 'NAATEELib.Controllers.LoginController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +628
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +204

Please guide me. I do not want to modify .config (xml) files.
thanks.

  • 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-25T20:47:57+00:00Added an answer on May 25, 2026 at 8:47 pm

    It seems you forgot to use a Windsor controller factory (the stack trace shows DefaultControllerFactory).

    Take a look at this Windsor – ASP.NET MVC tutorial, in particular part 2.

    EDIT: OP edited the question, code is already using MvcContrib’s Windsor controller factory. Either the registrations are wrong (recommend using MvcContrib’s RegisterControllers) or the controller factory isn’t correctly installed.

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

Sidebar

Related Questions

I want to register to get notified of all Java changes in Eclipse. I
I want to register a specific instance of an object for a type in
There is nested listviews and I want to register a button in the second
In my web application i have registration form, when user register i want to
I just want my apache to register some of my predefined environment so that
I want to build a web application where users can register and have a
when people register to my website i don't want to send them a verification
I want to know if it's possible to register a type library without using
I want to achieve something like this in C# 3.5: public void Register<T>() :
I want to do the following: 1: Add two dropdown list in the register.aspx

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.