hi there


my question is simple and i only need a hint.

"how could i develop a applications which can make a new EXE application. like this,.... the end user runs the application and when he clicks on a button named "create a new calculator", the application will create the exe for a new calculator. i can make the calculator, but don't know how to make it's EXE at my applications runtime.

please help

Dani AI

Generated

Short answer: yes — an application can produce an EXE at runtime. Which technique you pick depends on language, how much control you need, and whether the generated EXE must be standalone.

Common options (trade-offs):

  • Generate source and compile it. For managed code you can compile in-process (compiler APIs) or launch the platform compiler as a subprocess. This is straightforward and keeps the produced EXE as a normal program the user can run elsewhere.
  • Emit an assembly directly (Reflection.Emit / IL generation). More control, no human-readable source, but more work for anything nontrivial.
  • Ship a binary template or a plugin host. Copy a prepared EXE, change embedded resources/config, or have a single host application that loads small “calculator definitions” (script/DSL) instead of creating separate EXEs — often simpler and safer.

A small .NET example using the Roslyn compiler API (illustrates the in-process compile approach):

using System.IO;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;

string source = "using System; class P{ static void Main(){ Console.WriteLine(\"Hello\"); } }";
var tree = CSharpSyntaxTree.ParseText(source);
var refs = new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) };
var comp = CSharpCompilation.Create("Calc.exe", new[] { tree }, refs, new CSharpCompilationOptions(OutputKind.ConsoleApplication));
using (var fs = File.Create("Calc.exe"))
{
    var emitResult = comp.Emit(fs);
    if (!emitResult.Success)
    {
        foreach (var d in emitResult.Diagnostics) System.Console.WriteLine(d);
    }
}

Practical notes and gotchas:

  • Include correct references (framework/core assemblies) when compiling; this is a common failure point.
  • File permissions, antivirus, and code signing matter if EXEs are created on-demand. Unsigned, freshly-created binaries can be flagged.
  • Never compile or execute untrusted code without sandboxing.
  • If target is C/C++, the usual route is generating source and invoking the native compiler (cl/gcc/clang) or using LLVM libraries for in-process code gen.

As wants a “create a new calculator” button, the simplest path is generating source from a template and compiling it (or using a host+script approach if you want many tiny variations without creating many files). This complements the build-time vs runtime ideas already mentioned by and .

Recommended Answers

All 5 Replies

>but don't know how to make it's EXE at my applications runtime.

If you are running Visual studio then VS will do it for you. Please check out Bin\Debug or Bin\Release folder under your project folder.

i didn't mean the EXE for my application. i mean "how to make EXE (let's say for a new calculator) at runtime of my application.

I think you want to create "Setup" or "Installation" (deploying) of your window app. Isn't that?

no no ... i didnt mean setup. ... for example AUTOPLAY MEDIASTUDIO creates a new media player for the end user. i want to do that way just for a calculator. got it?

You should take a look at Microsoft.Build.BuildEngine. Please don't ask for some code piece. I had a tough time trying to get this thing work :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.