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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:15:06+00:00 2026-05-15T10:15:06+00:00

I remember when .NET 4 was in beta there was a video of a

  • 0

I remember when .NET 4 was in beta there was a video of a developer that made a command-line app that he could type C# code into and it would compile the code on the fly. The idea was that the compiler was now available in the .NET language.

Anyone recall where this is? I need to create an application with a small macro language and I would love to use C# as that macro language, but I don’t know where to find this library..

  • 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-15T10:15:06+00:00Added an answer on May 15, 2026 at 10:15 am

    You can use the CSharpCodeProvider class to compile assemblies at runtime.

    You’ll need to make a boilerplate template to wrap the macro commands in a static method in a class.

    For example:

    static readonly Assembly[] References = new[] { typeof(Enumerable).Assembly, typeof(Component).Assembly };
    public Action CompileMacro(string source) {
        var options = new CompilerParameters(References.Select(a => a.Location).ToArray()) {
            GenerateInMemory = true
        };
        string fullSource = @"public static class MacroHolder { public static void Execute() { \r\n" + source + "\r\n} }";
        try {
            var compiler = new CSharpCodeProvider(new Dictionary<string, string> { { "CompilerVersion", "v4.0" } });
    
            var results = compiler.CompileAssemblyFromSource(options, fullSource);
    
            if (results.Errors.Count > 0)
                throw new InvalidOperationException(String.Join(
                    Environment.NewLine, 
                    results.Errors.Cast<CompilerError>().Select(ce => ce.ErrorText)
                ));
    
            return (Action)Delegate.CreateDelegate(
                typeof(Action),
                results.CompiledAssembly.GetType("MacroHolder").GetMethod("Execute")
            );
        } finally { options.TempFiles.Delete(); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember reading once that .NET had a built in configSection handler that could
I vaguely remember there is a .NET type name with the suffix 2. I
So, I've read a bit about .net and MVC. I remember reading something that
I seem to remember a tool that could be used at runtime to tell
In .net 1.1 I seem to remember I had to declare web controls that
I'm building a .net web app and using Forms authentication with cookies to remember
I remember when ASP.NET MVC was new, there was a lot of contention over
I know that using .net VSTO there is no way to do this. but
I seem to remember there was a website where you could view other websites
I distinctly remember from the early days of .NET that calling ToString on a

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.