Dynamic Creation Of Assemblies/Apps

The other day I was discussing code generation with a collegue and he was discussing a hyperthetical siuation where it would be possible to create source code at runtime and even compile it to create apps at runtime. Now I didnt know much about this, but I decided to have a little exploratory look into this. As ever .NET amazed me (again) and had 2 interesting namespaces to do this.

  • System.CodeDom : Which allows the generation of a CodeCompileUnit which can be then generated into a source code file for any .NET language
  • System.CodeDom.Compiler : Is able to create a Assembly/Exe at runtime from a source code file.

I have written a small demo application and an accompanying article about this over at http://www.codeproject.com, this is available right here, if you are interested. This is what it looks like anyway:

codedombig.png

The application creates a simple source code file and compiles it into an Exe and runs it, all at runtime. Cool.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: