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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:20:27+00:00 2026-06-08T08:20:27+00:00

Possible Duplicate: Use reflection to invoke an overridden base method Normally I can call

  • 0

Possible Duplicate:
Use reflection to invoke an overridden base method

Normally I can call my base class from within an overridden method like this:

public override void Foo(Bar b)
{
    base.Foo(b);
}

How can I make this same call with reflection?

Edit: to explain a bit, I’m trying to use AOP to guard my library’s entry points from uninitialized operation (in my case there is no “initialize” call prior to the library’s usage). So the relevant calls will technically end up inside the class (by virtue of the AOP), but the pre-compiled code will be written in a separate class. In other words, I want the following advice applied to all of my entry points:

if (!initialized)
    return base.<method>(<arguments>);

I suppose the IL trick shown in Use reflection to invoke an overridden base method will work for me – I was just hoping there was something cleaner in my case since it feels more legitimate.

  • 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-08T08:20:28+00:00Added an answer on June 8, 2026 at 8:20 am

    EDIT: OK, so a bit of clarification; you’re not trying to call the base class’s implementation from outside either class. Instead, from within the overridden class, you want to reflectively call the parent method’s implementation.

    … Why? Your object statically knows what it is, and therefore statically knows what its base class is. You can’t have two base classes, and you can’t dynamically “assign” a base class to a pre-existing child class.

    To answer your question, you can’t. Any attempt to reflectively call “Foo” using the current instance will infinitely recurse, because the invocation of a MethodInfo makes the method call as if it were coming from outside (’cause it is), and so the runtime will obey inheritance/overriding behaviors. You would have to use the IL hack from the related question.

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

Sidebar

Related Questions

Possible Duplicate: Use of class definitions inside a method in Java Can we have
Possible Duplicate: c# Can I use reflection to inspect the code in a method?
Possible Duplicate: Enumerating through an object's properties (string) in C# Can I use reflection
Possible Duplicates: How to use reflection to call generic Method? Select Right Generic Method
Possible Duplicate: Can you use reflection to find the name of the currently executing
Possible Duplicate: Can we use any other TAG inside <ul> along with <li>? Or
Possible Duplicate: How to use include within a function? i have two file inc.php
Possible Duplicate: Why use a framework with PHP? To begin with, I just can
Possible Duplicate: Use LINQ to read all nodes from XML I am trying to
Possible Duplicate: How to use my own sqlite database? Full Android Database Helper class

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.