1

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

1
  • This SO question might give you some answers on when and how to do this. Commented Nov 4, 2009 at 9:05

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

2

Sure. Have a look at the CSharpCodeProvider class.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.