views:

461

answers:

4

As described in the title I would like to develop a Windows Forms Application in .NET that is capable of creating at run-time another .NET command line or windows form executable and let me save it to disk.

Do you have any ideas if it is possible and how to proceed?

#Region "Some more info"

I would like to create a form where the user can define a path of an executable and a path for an icon/image.

When he/she presses the build button the program create a new .NET exe that the user can save to the disk.

This exe's icon is the icon selected in during creation and when launched it starts the process selected during creation and exit.

Practically a mini launcher

#EndRegion

Thanks a lot, Marco

+4  A: 

Absolutely - you can just use the CSharpCodeProvider class and get it to generate an assembly on disk. That's assuming you've got C# code you want to build, of course (e.g. code that the user typed in). There are similar providers for other languages - or you can decide at execution time using CodeDomProvider.CreateProvider

If you don't have C# code to compile, there are probably still ways of doing what you want - but you'll need to be specific about what you want this new executable to do.

Jon Skeet
thank you, i am on the way to get it working...
marco.ragogna
+1  A: 

I see two ways for this:

  1. Creating a text file, containing the C# code of desired application. Compiling in using csc.exe
  2. Creating classes and implementation dynamically using Reflection possibilitie
Boris Modylevsky
+2  A: 

Sure. Have a look at the CSharpCodeProvider class.

nikie
A: 

This SO question might give you some answers on when and how to do this.

Sorin Comanescu