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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:55:07+00:00 2026-06-01T15:55:07+00:00

Greetings fellow members, the situation in question is such: public abstract class BaseClass {

  • 0

Greetings fellow members, the situation in question is such:

public abstract class BaseClass
{
    protected BaseClass()
    {
        // some logic here
    }

    protected BaseClass(Object parameter) : this()
    {
        // some more logic
    }
}

public class Descendant : BaseClass
{
   // no constructors
}

I’m trying to call Activator.CreateInstance on the Descendant class, but no constructor is found.

Do I need to explicitly define it on the Descentant class?

The bindings I’ve used are these: BindingFlags.Instance | BindingFlags.NonPublic

Note 1: I’m calling AppDomain.CreateInstanceAndUnwrap() in reality, if it should have some influence.

 domain.CreateInstanceAndUnwrap(path, typeName, false, BindingFlags.Instance |
     BindingFlags.NonPublic, null, new[] { parameter }, null, null);

Note 2: If I explicitly define the protected constructor in the Descendant class then it works, but I’d like to avoid this if possible.

  • 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-06-01T15:55:08+00:00Added an answer on June 1, 2026 at 3:55 pm

    You cannot use Activator.CreateInstance, but in Full Trust environments you should be able to locate and call the constructor directly by reflection.

    Actually, your Descendant class automatically provides a public constructor that does a pass-through to the protected constructor of the base class. This should work just fine:

    Activator.CreateInstance(typeof(Descendant))
    

    Okay, so now I realize that you’re trying to invoke the non-default constructor. Unfortunately for you, this is simply not allowed. Invoking the constructor on the base class directly won’t work because the base class is abstract. You need to have a constructor (either auto-generated or explicitly defined) on the descendant class in order to construct an object.

    You could create a pass-through constructor on the Descendant class, but your comments make it sound like you’re trying to avoid forcing implementers to pass a value through in their constructor. What you probably really want is an initialization method that you can call after constructing the object:

    // Define other methods and classes here
    public abstract class BaseClass
    {
        protected BaseClass()
        {
            // some logic here
        }
    
        protected Object Parameter {get; private set;}    
    
        public virtual void Initialize(Object parameter)
        {
            Parameter = _parameter;
            // some more logic
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings Community! <object id=myExperienceXXXXXXXX class=BrightcoveExperience> <param name=bgcolor value=#FFFFFF /> <param name=width value=448 /> <param
greetings all i have a domain class named car and i have an object
Greetings to all! This is my first question here on stackoverflow. I have a
Greetings, fellow StackOverFlow members. I have just begun to learn how to program web-enabled
Greetings, fellow coders! I have this table that contains categories and subcategories (actually I
Greetings all, Is there any issue in the following logic for allocating 2D array:
Greetings, I've read some threads about this topic, but actually I was unable to
Greetings fellow earthlings. I'm researching methods of caching data retrieved from various database tables
greetings from Iceland! To begin with, I have searched both with google and here
Greetings. I'm just getting started with the boost::asio library and have run into some

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.