This is possible, see the CSharpCodeProvider class . Here is a tutorial on how it can be used to compile assemblies at runtime dynamically, now who, who adds image resources, but from what’s there, it’s easy to adapt the code to do what you ask.
Creating .NET assemblies at run time
source
share