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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:41:07+00:00 2026-05-27T18:41:07+00:00

I have the following: public class BaseController : Controller { protected ISequenceService _sequence; public

  • 0

I have the following:

    public class BaseController : Controller
    {
        protected ISequenceService _sequence;

        public BaseController()
        {
        }

        [InjectionConstructor]
        public BaseController(ISequenceService sequence)
        {
            _sequence = sequence;
        }


 public class ProductsController : BaseController
    {

        public ProductsController(
            IService<Account> accountService,
            IService<Product> productService
            ) {
            _account = accountService;
            _product = productService;   
        }

I have been trying everything I can think of to get the BaseController one parameter constructor parameter called. However the parameterless constructor is always called. When I remove the parameterless constructor I get an error.

Is it possible to have a derived class and no parameterless constructor in the parent ? Is there some way that I can configure Unity to call the one parameter constructor?

  • 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-27T18:41:07+00:00Added an answer on May 27, 2026 at 6:41 pm

    You must call a constructor of the base class. Most of the time, that means calling the default constructor and if you leave it out, it will be done for you implicitly. You can specify which constructor to call using the following syntax:

    public ProductsController(IService<Account> accountService,
                              IService<Product> productService)
        : base((ISequenceService)someISequenceService) // calls the one parameter constructor
                                                       // of the base class
    {
        //...
    }
    

    Trying to construct a derived class without initializing the base class first is just not going to work.

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

Sidebar

Related Questions

i have the following base controller... public class BaseController : Controller { protected override
I have the following code: public abstract class BaseController : Controller { public IUserService
I have the following code public class BaseController : Controller { SqlConnection con; DataSet
I have the following class: public class Account { public int AccountID { get;
I have the following class public class Account { IEnumerable<AccountData> Data { get; set;
I have a base class looking like this: public class BaseController : Controller {
I have following class public abstract class Rule { protected Rule() { Nodes =
For simplicity's sake, lets say I have the following Abstract Base Controller Class: public
If I have the following code: [TestFixture] public class MyBaseTest { protected ISessionManager _sessionManager;
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int

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.