Reflection Emit Sample

Sample Overview

This sample demonstrates how to use reflection emit. Reflection emit is a runtime feature that allows code to create dynamic assemblies, modules and types. These types can be created for the purpose of creating dynamic instances of them and using them. Reflection emit can also be used to generate an assembly and persist it to disk as an executable file or DLL.

The sample allows you several interactive options:

The user can run the application multiple times to explore the different options. 

The following briefly describes the classes and technologies used by this sample.

Sample Source and Build Output Locations

The sample source is found in sscli\samples\howto\reflection\emit. 

The source file is:

The build output location is %TARGETCOMPLUS%\samples\howto\reflection\emit.  The output file is an executable assembly named reflectionemit.exe.

Building the Sample

All samples are built from the buildall script. 

You can also build all the samples by switching to the root of the sample directory, sscli\samples, and typing build -c.

You can build this specific sample by switching to the sample directory and typing build -c.

Running the Sample

These steps require that the Shared Source CLI (SSCLI) be already built and functional.

  1. Run env.bat or source the env.csh or env.sh script files depending on your platform.
  2. Switch to the %TARGETCOMPLUS%\samples\howto\reflection\emit directory.
  3. Type the following command:

    clix reflectionemit.exe


Copyright (c) 2002 Microsoft Corporation. All rights reserved.