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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:18:44+00:00 2026-06-17T06:18:44+00:00

Can someone explain to me what needs to be loaded into the stack prior

  • 0

Can someone explain to me what needs to be loaded into the stack prior to making a function call via reflection.emit?

I have a very simple method

public static void Execute(string 1, string 2)

I want to generate the method in the following class dynamically (forget the rest, I got them sorted out)

public class Test{
    public string s1;

    public void Run(string s2)
    {
        MyOtherClass.Execute(s2,s1)
    }
}

I have a copy of the above test, for reference, and I noticed the following opcodes were emitted, prior to the “call”.

  1. ldarg_1
  2. ldarg_0
  3. ldfld

The question is what’s ldarg_0 doing there? I only need 2 arguments for the call, why does the CLR requires ldarg_0 to be pushed to the stack?

  • 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-17T06:18:46+00:00Added an answer on June 17, 2026 at 6:18 am

    arg.0 contains this and is required by ldfld string Test:s1 to push this.s1 onto the stack.

    .method public hidebysig instance void Run(string s2) cil managed
    {
        .maxstack 8                                      // maximum stack size 8
        ldarg.1                                          // push argument s2
        ldarg.0                                          // push this
        ldfld string Test::s1                            // pop this, push this.s1
        call void MyOtherClass::Execute(string, string)  // call
        ret                                              // return
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone explain to me when <?= needs to be used or why this
Here another bash command that needs some explanation. Can someone explain what are does
Wow, is this way more complicated than it needs to be. Can someone explain
Can someone please explain me why would a UDP Server not need to use
I don't understand the need for self-joins. Can someone please explain them to me?
Can someone explain this simple, yet deceiving, anomaly? There are two models, where B
Can someone explain me why this works: select val1, val2, count(case when table2.someID in
Can someone explain why, in this situation, scandir is getting my directory, but the
Can someone explain step by step how this query is processed? SELECT F.ID, F.FirstName,
Can someone explain why it's best use is for prototyping? Should it not be

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.