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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:28:12+00:00 2026-05-16T10:28:12+00:00

I had some problems figuring out a good title, but hopefully the code examples

  • 0

I had some problems figuring out a good title, but hopefully the code examples in this post are clear enough.

Is it possible, with the help of expression trees (or some other technique), to traverse the whole method “call stack”? Worded differently: When I get an expression tree from an Action-delegate, I would like to traverse inside the statements which happen inside the delegate.

I think it’s best to move into examples as soon as possible… I have an abstract class called Command. Inside the Command is the following method:

protected void Run()
{
    RunCommand (() => this.Execute());
}

Execute is an abstract method which is implement by my sub classes. Here’s an example of one Execute-method:

    protected override void Execute()
    {
        var data = new RegistrationData {HomeTown = "town"};
        service.SendNewRegistration(data);
    }

In my RunCommand-method I would like to get my hands on the statements inside the Execute-method. The method is defined as following:

protected void RunCommand(Expression<Action> expression)
{
    // Is it possible to find out that we're calling SendNewRegistration
    // of a service-instance in our expression?

    expression.Compile().Invoke();
}

Before calling the Invoke, is it possible to find out what happens inside the sub classes Execute-method? What is declared, what methods are executed and what parameters are used?

I tried to extend the ExpressionVisitor to see what is happening and made it to log VisitMethodCall-executions:

    protected override Expression VisitMethodCall(MethodCallExpression m)
    {
        Debug.WriteLine(m.Method.Name);
        return m;
    }

And the output was: Execute. So that didn’t take me far. Is it somehow possible to the reach the statements inside the Execute-method?

  • 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-16T10:28:12+00:00Added an answer on May 16, 2026 at 10:28 am

    No – you cannot do this. Expression trees only go as deep as the lambda itself.

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

Sidebar

Related Questions

I had some good insight to an earlier post regarding this, but I have
I had some problems doing this but one way of doing this is listed
I've recently moved to Java, but I've had some problems with variable aliasing. I've
I had this problem some time ago and I gave up but lately it
I began taking up Heroku again, but have had some problems trying to get
We had some problems this morning and need to rollback our database for about
I have some problems figuring out how to group to certain variables in javascript.
I had some problems printing out a student store with which I used an
I had some problems with my subversion server and i had to restore it
I've had some problems with a Django application after I deployed it. I use

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.