This documentation is archived and is not being maintained.

ICodeCompiler Interface

Defines an interface for invoking compilation of source code or a CodeDOM tree using a specific compiler.

Namespace:  System.CodeDom.Compiler
Assembly:  System (in System.dll)

public interface ICodeCompiler

The ICodeCompiler type exposes the following members.

Public methodCompileAssemblyFromDomCompiles an assembly from the System.CodeDom tree contained in the specified CodeCompileUnit, using the specified compiler settings.
Public methodCompileAssemblyFromDomBatchCompiles an assembly based on the System.CodeDom trees contained in the specified array of CodeCompileUnit objects, using the specified compiler settings.
Public methodCompileAssemblyFromFileCompiles an assembly from the source code contained within the specified file, using the specified compiler settings.
Public methodCompileAssemblyFromFileBatchCompiles an assembly from the source code contained within the specified files, using the specified compiler settings.
Public methodCompileAssemblyFromSourceCompiles an assembly from the specified string containing source code, using the specified compiler settings.
Public methodCompileAssemblyFromSourceBatchCompiles an assembly from the specified array of strings containing source code, using the specified compiler settings.


In the .NET Framework versions 1.0 and 1.1, code providers consist of implementations of CodeDomProvider, ICodeGenerator, ICodeParser, and ICodeCompiler. In the .NET Framework 2.0, the CreateGenerator, CreateParser, and CreateCompiler methods are obsolete, and the methods of ICodeGenerator and ICodeCompiler are directly available in the CodeDomProvider class. You should override those methods in your code provider implementation and not call the base methods.

The ICodeCompiler interface can be implemented for a specific compiler to enable developers to programmatically compile assemblies from Code Document Object Model (CodeDOM) compile units, strings containing source code, or source code files.

The ICodeCompiler interface provides the capability to invoke compilation with specified parameters at runtime and access information related to compilation after compilation occurs, including the result code, and any errors or warnings the compiler returns. Each compile method accepts a CompilerParameters object that indicates settings for the compiler, and returns a CompilerResults object that indicates the results of the compilation.

Compiler developers should provide an implementation of this interface to support dynamic compilation. CodeDomProvider implementers should also consider implementing this interface to provide programmatic compilation capability for the language that they are providing CodeDom support for.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

  • SecurityAction.LinkDemand 

    for full trust for the immediate caller. This interface cannot be used by partially trusted code.

  • SecurityAction.InheritanceDemand 

    for full trust for inheritors. Classes that implement this interface cannot be inherited by partially trusted code.

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.