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 中, 程式碼提供者是由CodeDomProviderICodeGeneratorICodeParserICodeCompiler的執行所組成。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.

適用於

另請參閱