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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:42:33+00:00 2026-05-23T11:42:33+00:00

I want to write a code generator and save these codes with mvp pattern,

  • 0

I want to write a code generator and save these codes with mvp pattern, can I use Reflection.Emit as a solution or CodeDom is better?

EDIT————–

I have to do 2 work, firstly I want to compile this code at runtime and run it and secondly generate the source code as an option.

  • 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-23T11:42:33+00:00Added an answer on May 23, 2026 at 11:42 am

    Although you can achieve some aspects of your question with both Namespaces (System.CodeDom and System.Reflection.Emit) you can’t mix the two different concepts and use the option(s) that better fits whatever you want to do.

    If you just want to generate and compile C#\VB code maybe you want do use System.CodeDom:

    This namespace can be used to model
    the structure of a source code
    document that can be output as source
    code in a supported language using the
    functionality provided by the
    System.CodeDom.Compiler namespace.

    Check this small example on how to define a method through CodeDom:

    // Defines a method that returns a string passed to it.
    CodeMemberMethod method1 = new CodeMemberMethod();            
    method1.Name = "ReturnString";
    method1.ReturnType = new CodeTypeReference("System.String");
    method1.Parameters.Add( new CodeParameterDeclarationExpression("System.String", "text") );
    method1.Statements.Add( new CodeMethodReturnStatement( new CodeArgumentReferenceExpression("text") ) );            
    
    // A C# code generator produces the following source code for the preceeding example code:
    
    //    private string ReturnString(string text) 
    //    {
    //        return text;
    //    }
    

    As for the System.Reflection.Emit its used to generate and manipulate MSIL (Microsoft Intermediate Language) which is lowest-level human-readable programming language defined by the Common Language Infrastructure specification and used by the .NET Framework. Note that MSIL is now known as CIL (Common Intermediate Language):

    The System.Reflection.Emit namespace
    contains classes that allow a compiler
    or tool to emit metadata and Microsoft
    intermediate language (MSIL) and
    optionally generate a PE file on disk.
    The primary clients of these classes
    are script engines and compilers.

    The use of this approach leads you to learn CIL bytecode instructions which is a rather difficult and complex task even if you’re familiar with assembly code and might not be ideal if what you want is rather simple and fast to implement. Check wikipedia article on CIL and CIL instructions list for a first impression.

    • 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 web-based code generator for a Python crawler. Its aim
I often find I want to write code something like this in C#, but
I am a AS3 novice learning PureMVC and want to write code following best
I'm overriding WndProc, so I want to write code like if (m.Msg == WM_COMMAND)
How do I write code to connect through Windows VPN client? I want this
The code that I want to write is like this: void MethodOnThreadA() { for
I want to write an NSOutputStream to a server with apple's sample code: NSURL
I want to write a simple task which will update and commit source code
I want to write a .xml file using the following code into the App_Data/posts.
I want to write a simple web proxy, for exercise. Here's the code I

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.