ICodeCompiler 接口

定义

定义用于调用源代码编译的接口或使用指定编译器的 CodeDOM 树。Defines an interface for invoking compilation of source code or a CodeDOM tree using a specific compiler.

public interface class ICodeCompiler
public interface ICodeCompiler
type ICodeCompiler = interface
Public Interface ICodeCompiler
派生

注解

备注

在 .NET Framework 版本1.0 和1.1 中, 代码提供CodeDomProvider程序由ICodeParserICodeGenerator、和ICodeCompiler的实现组成。In the .NET Framework versions 1.0 and 1.1, code providers consist of implementations of CodeDomProvider, ICodeGenerator, ICodeParser, and ICodeCompiler. .NET Framework 2.0.NET Framework 2.0在中CreateCompiler , ICodeGenerator ICodeCompiler 、和方法CodeDomProvider已过时, 并且和的方法直接在类中可用。 CreateParser CreateGeneratorIn the .NET Framework 2.0.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.

可以为特定编译器实现接口,使开发人员能够以编程方式从代码文档对象模型(CodeDOM)编译单元、包含源代码的字符串或源代码文件中编译程序集。ICodeCompilerThe 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.

ICodeCompiler接口提供了在运行时调用具有指定参数的编译的功能, 并提供编译后的与编译相关的访问信息 (包括结果代码) 以及编译器返回的任何错误或警告。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. 每个编译方法都CompilerParameters接受一个指示编译器设置的对象, 并返回一个CompilerResults指示编译结果的对象。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实现者还应考虑实现此接口, 以便为其提供 CodeDom 支持的语言提供编程编译功能。CodeDomProvider implementers should also consider implementing this interface to provide programmatic compilation capability for the language that they are providing CodeDom support for.

方法

CompileAssemblyFromDom(CompilerParameters, CodeCompileUnit)

使用指定的编译器设置从指定的 System.CodeDom 所包含的 CodeCompileUnit 树中编译程序集。Compiles an assembly from the System.CodeDom tree contained in the specified CodeCompileUnit, using the specified compiler settings.

CompileAssemblyFromDomBatch(CompilerParameters, CodeCompileUnit[])

基于包含在 System.CodeDom 对象的指定数组中的 CodeCompileUnit 树,使用指定的编译器设置编译程序集。Compiles an assembly based on the System.CodeDom trees contained in the specified array of CodeCompileUnit objects, using the specified compiler settings.

CompileAssemblyFromFile(CompilerParameters, String)

从包含在指定文件中的源代码,使用指定的编译器设置编译程序集。Compiles an assembly from the source code contained within the specified file, using the specified compiler settings.

CompileAssemblyFromFileBatch(CompilerParameters, String[])

从包含在指定文件中的源代码,使用指定的编译器设置编译程序集。Compiles an assembly from the source code contained within the specified files, using the specified compiler settings.

CompileAssemblyFromSource(CompilerParameters, String)

从包含源代码的指定字符串,使用指定的编译器设置编译程序集。Compiles an assembly from the specified string containing source code, using the specified compiler settings.

CompileAssemblyFromSourceBatch(CompilerParameters, String[])

从包含源代码的字符串的指定数组,使用指定的编译器设置编译程序集。Compiles an assembly from the specified array of strings containing source code, using the specified compiler settings.

安全性

LinkDemand
完全信任直接调用方。for full trust for the immediate caller. 部分受信任的代码不能使用此接口。This interface cannot be used by partially trusted code.

InheritanceDemand
完全信任继承者。for full trust for inheritors. 实现此接口的类不能由部分受信任的代码继承。Classes that implement this interface cannot be inherited by partially trusted code.

适用于

另请参阅