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

  • Home
  • SEARCH
  • 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 6375371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:36:23+00:00 2026-05-25T01:36:23+00:00

Hi i want to compile a class at runtime using CodeDom and generate in

  • 0

Hi i want to compile a class at runtime using CodeDom and generate in memory. How do i go about running the compiled code from memory?

My TextFile Resource:

using System.IO;
using System;

namespace Exe_From_Memory
{
    static class MemoryExe
    {
        static void Main()
        {
            string strText = "[TEXT]";
            Console.WriteLine(strText);
            Console.Read();
        }
    }
}

My actual application which compiles the textfile

private void exeButton_Click(object sender, EventArgs e)
{
    string text = textBox1.Text;
    string source;

    source = Properties.Resources.MemoryExe;
    source = source.Replace("[TEXT]", text);

    CompilerParameters _CompilerParameters = new CompilerParameters();

    _CompilerParameters.ReferencedAssemblies.Add("System.dll");
    _CompilerParameters.GenerateExecutable = true;
    _CompilerParameters.GenerateInMemory = true;

    _CompilerParameters.IncludeDebugInformation = false ;

    CSharpCodeProvider _CSharpCodeProvider = new CSharpCodeProvider();
    CompilerResults _CompilerResults = _CSharpCodeProvider.CompileAssemblyFromSource(_CompilerParameters, source);

    Assembly _Assembly = _CompilerResults.CompiledAssembly;
    MethodInfo mi = _Assembly.EntryPoint;
    object o = _Assembly.CreateInstance(mi.Name);
    mi.Invoke( o, null);

    foreach (CompilerError _CompilerError in _CompilerResults.Errors)
    {
        MessageBox.Show(_CompilerError.ToString());
    }
}

The debugger simply says:
‘Exe From Memory.vshost.exe’ (Managed): Loaded ‘r8ztr3t0’
Since its loaded why doesnt the console window show?

  • 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-25T01:36:24+00:00Added an answer on May 25, 2026 at 1:36 am

    All Invoke() does is that it calls the method, it doesn’t create new application. And since you’re running a windows application that doesn’t have a console, the text isn’t written anywhere.

    If you want to show the console window from your application, you can use the Win32 AllocConsole() function.

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

Sidebar

Related Questions

I want to compile the following line of code from http://code.google.com/p/enhsim : enh::eout <<
I want to compile C code from the Command Prompt in Windows. I have
I want to compile GCC and binutils which would produce 64bit executables. From GNU
I want to compile a batch file into an EXE file using C++. I
I want to compile a simple hello-world-style program using the Windows command line. cl
When you want to inherit from a class in C++, is it illegal to
I want to download the code from http://pastehtml.com/view/awono3xoq.txt , save it to a string,
This is best explained using code. I have a generic class that has a
when i want compile my app with the Distribution or Release method i get
I want to compile a project differently, according to a constant defined by #define,

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.