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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:03:10+00:00 2026-05-14T05:03:10+00:00

In .Net, you can generate byte code in memory, and presumably save the resulting

  • 0

In .Net, you can generate byte code in memory, and presumably save the resulting program to a .exe file. To do the first step, I have the following test code adapted from http://www.code-magazine.com/Article.aspx?quickid=0301051

var name = new AssemblyName();
name.Name = "MyAssembly";
var ad = Thread.GetDomain();
var ab = ad.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run);
var mb = ab.DefineDynamicModule("MyModule");
var theClass = mb.DefineType("MathOps", TypeAttributes.Public);
var retType = typeof(System.Int32);
var parms = new Type[2];
parms[0] = typeof(System.Int32);
parms[1] = typeof(System.Int32);
var meb = theClass.DefineMethod("ReturnSum", MethodAttributes.Public, retType, parms);
var gen = meb.GetILGenerator();
gen.Emit(OpCodes.Ldarg_1);
gen.Emit(OpCodes.Ldarg_2);
gen.Emit(OpCodes.Add_Ovf);
gen.Emit(OpCodes.Stloc_0);
gen.Emit(OpCodes.Br_S);
gen.Emit(OpCodes.Ldloc_0);
gen.Emit(OpCodes.Ret);
theClass.CreateType();

How do you do the second step, and save the result to a .exe?

  • 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-14T05:03:10+00:00Added an answer on May 14, 2026 at 5:03 am

    I think you might be looking for AssemblyBuilder.Save

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

Sidebar

Related Questions

Is there a tool that can generate sequence diagrams from running .NET code?
With ASP.NET MVC (or using HttpHandlers) you can dynamically generate URLs, like the one
Is there a .NET library I can use to programmatically generate my own GIF
Just wondering if a .NET app can be compiled down to native machine code
I understand how Lucene.net can work for text indexing. Will I be able to
In .Net you can read a string value into another data type using either
Can u give me a simple function in vb.net which can take number of
When you compile windows application in .NET you can set Platform Target to be
When you use the WebBrowser control in .NET you can embed an instance of
Anyone know of a control for asp.net that can achieve this either server or

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.