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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:58:23+00:00 2026-05-30T06:58:23+00:00

I have write some function to create an exe file using ILGenerator. What I

  • 0

I have write some function to create an exe file using ILGenerator. What I want is to show to user the IL language generated whithout using external tools like ILDasm or Reflector.

during the execution of my program I have added each OpCode to ILGenerator, so I can save each of this OpCode in a list using a string with the OpCode representation but I wish prefer to get the IL code directly. Can it be done?

Important: I’m using Mono 2.6.

  • 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-30T06:58:25+00:00Added an answer on May 30, 2026 at 6:58 am

    As Hans Passant and svick had said, the answer is Mono.Cecil. Let’s see:

    using Mono.Cecil;
    using Mono.Cecil.Cil;
    
    [...]
    
    
    public void Print( ) {
        AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly( this.module_name );
    
        int i = 0, j = 0;
        foreach ( TypeDefinition t in assembly.MainModule.Types ) {
            if ( t.Name  == "FooClass" ) {
                j = i;
            }
            i++;
        }
    
        TypeDefinition type = assembly.MainModule.Types[ j ];
    
        i = j = 0;
        foreach ( MethodDefinition md in type.Methods ) {
            if ( md.Name == "BarMethod" ) {
                j = i;
            }
            i++;
        }
    
        MethodDefinition foundMethod = type.Methods[ j ];
    
        foreach( Instruction instr in foundMethod.Body.Instructions ) {
            System.Console.WriteLine( "{0} {1} {2}", instr.Offset, instr.OpCode, instr.Operand );
        }
    }
    

    Sure it can be done more efficient but it solves my problem.

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

Sidebar

Related Questions

I want to write a function to create an empty square matrix have size
I'd like to write a function that would have some optional code to be
I'm an avid vim user and have started to write some SQL code recently.
I want to write some javascript and have it call into the DOM for
I have a simple function to create a gzip file. This function work fine
The background: I have a function which takes some parameters. I want to have
So far I have managed to write some code that should print the source
I have been attempting to write some routines to read RSS and ATOM feeds
I have been starting to write some reasonably large and or confusing MySQL queries
I have to use windows to write some shell scripts. I decided to 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.