ICodeCompiler 介面

定義

定義一個介面,用於叫用原始程式碼或使用特定編譯器之 CodeDOM 樹狀結構的編譯。

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

備註

注意

在 .NET Framework 1.0 和 1.1 版中,程式代碼提供者是由 、 ICodeGeneratorICodeParserICodeCompiler的實作CodeDomProvider所組成。 在 .NET Framework 2.0 中,、 和 方法已過時,且 和 ICodeCompiler 的方法可直接在 類別中使用。CreateCompilerCreateParserCreateGeneratorCodeDomProviderICodeGenerator 您應該覆寫程式代碼提供者實作中的那些方法,而不是呼叫基底方法。

ICodeCompiler您可以針對特定編譯程式實作 介面,讓開發人員以程序設計方式從程式代碼檔物件模型編譯元件, (CodeDOM) 編譯單位、包含原始程式碼的字串或原始程式碼檔案。

介面 ICodeCompiler 提供在運行時間使用指定參數叫用編譯的功能,以及在編譯發生後存取與編譯相關的資訊,包括結果碼,以及編譯程式傳回的任何錯誤或警告。 每個編譯方法都接受 CompilerParameters 對象,這個物件表示編譯程序的設定,並傳回 CompilerResults 物件,指出編譯的結果。

編譯程式開發人員應該提供這個介面的實作,以支援動態編譯。 CodeDomProvider 實作者也應該考慮實作此介面,為它們提供CodeDom支援的語言提供程式設計編譯功能。

方法

CompileAssemblyFromDom(CompilerParameters, CodeCompileUnit)

使用指定的編譯器設定,在指定的 System.CodeDom 所包含的 CodeCompileUnit 樹狀結構中,編譯一個組件。

CompileAssemblyFromDomBatch(CompilerParameters, CodeCompileUnit[])

使用指定的編譯器設定,根據 System.CodeDom 物件之指定陣列所包含的 CodeCompileUnit 樹狀結構,編譯一個組件。

CompileAssemblyFromFile(CompilerParameters, String)

使用指定的編譯器設定,在指定檔案所包含的原始程式碼中,編譯一個組件。

CompileAssemblyFromFileBatch(CompilerParameters, String[])

使用指定的編譯器設定,在指定檔案所包含的原始程式碼中,編譯一個組件。

CompileAssemblyFromSource(CompilerParameters, String)

使用指定的編譯器設定,在含有原始程式碼的指定字串中,編譯一個組件。

CompileAssemblyFromSourceBatch(CompilerParameters, String[])

使用指定的編譯器設定,在含有原始程式碼的指定陣列中,編譯一個組件。

適用於

另請參閱