Reflection.Emit

The Reflection.Emit API provides a means to dynamically create new assemblies. Using customized builders and generating Microsoft Intermediate Language (MSIL) or Common Intermediate Language (CIL) code enables programs to create new programs at runtime. These assemblies may be dynamically invoked or saved to file where they may be reloaded and invoked or used by other programs.

Dynamic assembly creation can be useful for back-ends to compilers or scripting engines on tools such as Web browsers. Using the Reflection.Emit API, any tool can be extended to dynamically support .NET or any other Common Language Infrastructure (CLI) compliant system. Listing 28.6 shows how to both generate a dynamic assembly and save it as a console ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.