CodeDomProvider.CompileAssemblyFromSource(CompilerParameters, String[]) 方法

定义

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

public:
 virtual System::CodeDom::Compiler::CompilerResults ^ CompileAssemblyFromSource(System::CodeDom::Compiler::CompilerParameters ^ options, ... cli::array <System::String ^> ^ sources);
public virtual System.CodeDom.Compiler.CompilerResults CompileAssemblyFromSource (System.CodeDom.Compiler.CompilerParameters options, params string[] sources);
abstract member CompileAssemblyFromSource : System.CodeDom.Compiler.CompilerParameters * string[] -> System.CodeDom.Compiler.CompilerResults
override this.CompileAssemblyFromSource : System.CodeDom.Compiler.CompilerParameters * string[] -> System.CodeDom.Compiler.CompilerResults
Public Overridable Function CompileAssemblyFromSource (options As CompilerParameters, ParamArray sources As String()) As CompilerResults

参数

options
CompilerParameters

一个 CompilerParameters 对象,它指示此编译的编译器设置。A CompilerParameters object that indicates the compiler settings for this compilation.

sources
String[]

要编译的源代码字符串的数组。An array of source code strings to compile.

返回

CompilerResults

指示编译结果的 CompilerResults 对象。A CompilerResults object that indicates the results of compilation.

例外

此方法和 CreateCompiler() 方法均不在派生类中重写。Neither this method nor the CreateCompiler() method is overridden in a derived class.

注解

备注

在 .NET Framework 版本1.0 和1.1 中,此方法由 ICodeCompiler 提供程序的方法返回的实现提供 CreateCompilerIn the .NET Framework versions 1.0 and 1.1, this method is provided by the ICodeCompiler implementation that is returned by the CreateCompiler method of the provider. 在版本2.0 中,可以直接在代码提供程序上调用此方法,即使代码提供程序未重写此方法。In version 2.0, this method can be called directly on the code provider even if it is not overridden by the code provider. 如果代码提供程序不重写此方法,则 ICodeCompiler 由基类调用实现。If the code provider does not override this method, the ICodeCompiler implementation is called by the base class.

继承者说明

如果重写此方法,则不能调用基类的相应方法。If you override this method, you must not call the corresponding method of the base class. 基类方法使用已过时的方法在派生类中创建一个生成器, CreateCompiler() 以便与使用代码编译器的预先存在的提供程序兼容。The base-class method creates a generator in the derived class using the obsolete CreateCompiler() method for compatibility with preexisting providers that use code compilers. 然后,基类方法调用实现中的等效方法 ICodeCompiler 来执行此函数。The base-class method then calls the equivalent method in the ICodeCompiler implementation to perform this function. NotImplementedException如果从不使用代码编译器的代码提供程序调用基类方法,则将收到。You will get a NotImplementedException if you call the base-class method from a code provider that does not use a code compiler.

适用于

另请参阅