0

Is it possible to create an application in c# that can itself create another application from source code it creates dynamically?

for example, application 1 runs and asks you some basic questions. then uses the answers to those questions to compile a brand new exe for you containing your answers inside the source code?

I hope that makes sense!

Martyn

SmithMart
  • 2,731
  • 18
  • 35
  • possible duplicate of [c# execute a string as code](http://stackoverflow.com/questions/1511376/c-sharp-execute-a-string-as-code) – Polynomial Dec 01 '11 at 12:26
  • possible duplicate of [Could .NET be parsed and evaluated at runtime](http://stackoverflow.com/questions/8327831/could-net-be-parsed-and-evaluated-at-runtime) – sehe Dec 01 '11 at 12:33

2 Answers2

3

Yes you can using the CSharpCodeProvider class. See this code project article which gives you the general idea:

Compiling and Executing Code at Runtime

Justin
  • 84,773
  • 49
  • 224
  • 367
  • My GoogleFu was weak today! Good link, just what I was looking for. Haven't had a really good look, but it looks like that class is just the ticket. – SmithMart Dec 01 '11 at 12:41
0

Do you really need to create a different application every time?

Creating a generic version of that application and then configuring it using a file from the other application might be easier.

svick
  • 236,525
  • 50
  • 385
  • 514
  • Im creating a wrapper for another application, so the application I am creating will take another exe file and some other bits as inputs, then compile a new EXE that will contain the file and install them all. Kind of a mini installer. – SmithMart Dec 01 '11 at 12:56