Hi,

I recently started programming in c# and I was wondering: How am I able to create a "builder program"?

For example:

I have a windows application with some strings that have to be customised by every person, I would like to have a GUI apart from it that allows the person to enter their values for such strings in textboxes, they can create build and it creates an EXE with the windows application with their settings being saved in strings.

Greetings

Joel

Dani AI

Generated

Short practical note for and anyone else following: there are two reliable ways to produce a customized EXE from a GUI builder — generate source and compile it, or modify an existing compiled assembly. Pick the one that fits your workflow and constraints (number of custom fields, need to preserve signing, cross-platform targets).

Generate-and-compile (recommended for clarity)

  • Make a small template class that holds the strings (not const if you plan to change them later). Replace placeholders with user input, then compile programmatically.
  • Use the Roslyn APIs to compile in-process (no shelling out), add the correct MetadataReference entries for the target runtime, and Emit to an output EXE. This gives full control over compilation and avoids fragile binary edits.

Example (Roslyn, minimal):

var tree = CSharpSyntaxTree.ParseText(sourceCode);
var refs = new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) };
var compilation = CSharpCompilation.Create("Custom.exe",
    new[] { tree }, refs,
    new CSharpCompilationOptions(OutputKind.ConsoleApplication));
var result = compilation.Emit("Custom.exe");

Binary rewriting (use when source is not available)

  • Use a library like Mono.Cecil to edit the IL or resource blobs inside an assembly. You can replace ldstr string operands or change field initializers. Important: compile-time const values are often inlined into callers, so prefer static readonly or resource-based storage if you want reliable post-build edits.
  • Caveats: signed (strong-name) assemblies must be re-signed after modification; antivirus heuristics sometimes flag on-the-fly-generated executables; changing IL needs careful testing.

Other practical points

  • Decide whether you want framework-dependent or self-contained EXEs up front; that affects references and publishing steps.
  • Validate and sanitize user input before embedding it into generated source.
  • If the goal is simple customization for end users, packaging a small runtime config may still be simpler and less error-prone than generating binaries.

For deeper reference on compile-time APIs and IL rewriting see the Roslyn docs and the Mono.Cecil project pages.

Recommended Answers

All 5 Replies

>I recently started programming in c# and I was wondering: How am I able to create a "builder program"?

Good thinking. You need more practices. I am sure you will be a good programmer.

There is a lot for you to learn in C#. I guess you need to start with simple application first rather than to jump to some advance programming . Learn the fundamental first and the language capabilities for you to properly design your applications.

May be this will help you, Search SharpDevelop. It is an opensource IDE for .net. Read its code specially on the part of "build" since you're aiming to create something like it.

I hope to give you some directions and even enough for you to start your dream app.

commented: Good advice. +9

Why do you need to create a builder app to do that? Could you not just use user configuration settings. (Properties.Settings in a forms app)

Why do you need to create a builder app to do that? Could you not just use user configuration settings. (Properties.Settings in a forms app)

It's not a form app, it's a terminal based application.
All I need is how to make the config class the strings in there should be able to be changed by the text boxes and compile the config with the other code i have by a click of a button.

Why do you need to create a builder app to do that? Could you not just use user configuration settings. (Properties.Settings in a forms app)

Thanks for the help, but that isn't exactly what im looking for.

More something like this:

[IMG][/IMG]

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.