CompilerResults 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示从编译器返回的编译结果。
public ref class CompilerResultspublic class CompilerResults[System.Serializable]
public class CompilerResultstype CompilerResults = class[<System.Serializable>]
type CompilerResults = classPublic Class CompilerResults- 继承
- 
				CompilerResults
- 派生
- 属性
示例
// Displays information from a CompilerResults.
public static void DisplayCompilerResults(System.CodeDom.Compiler.CompilerResults cr)
{
    // If errors occurred during compilation, output the compiler output and errors.
    if( cr.Errors.Count > 0 )
    {
        for( int i=0; i<cr.Output.Count; i++ )
            Console.WriteLine( cr.Output[i] );
        for( int i=0; i<cr.Errors.Count; i++ )
            Console.WriteLine( i.ToString() + ": " + cr.Errors[i].ToString() );
    }
    else
    {
        // Display information about the compiler's exit code and the generated assembly.
        Console.WriteLine( "Compiler returned with result code: " + cr.NativeCompilerReturnValue.ToString() );
        Console.WriteLine( "Generated assembly name: " + cr.CompiledAssembly.FullName );
        if( cr.PathToAssembly == null )
            Console.WriteLine( "The assembly has been generated in memory." );
        else
            Console.WriteLine( "Path to assembly: " + cr.PathToAssembly );
        // Display temporary files information.
        if( !cr.TempFiles.KeepFiles )
        {
            Console.WriteLine( "Temporary build files were deleted." );
        }
        else
        {
            Console.WriteLine( "Temporary build files were not deleted." );
            // Display a list of the temporary build files
            IEnumerator enu = cr.TempFiles.GetEnumerator();
            for( int i=0; enu.MoveNext(); i++ )
                Console.WriteLine( "TempFile " + i.ToString() + ": " + (string)enu.Current );
        }
    }
}
' Displays information from a CompilerResults.
Public Shared Sub DisplayCompilerResults(ByVal cr As System.CodeDom.Compiler.CompilerResults)
    ' If errors occurred during compilation, output the compiler output and errors.
    If cr.Errors.Count > 0 Then
        Dim i As Integer
        For i = 0 To cr.Output.Count - 1
            Console.WriteLine(cr.Output(i))
        Next i        
        For i = 0 To cr.Errors.Count - 1
            Console.WriteLine((i.ToString() + ": " + cr.Errors(i).ToString()))
        Next i
    Else
        ' Display information about the compiler's exit code and the generated assembly.
        Console.WriteLine(("Compiler returned with result code: " + cr.NativeCompilerReturnValue.ToString()))
        Console.WriteLine(("Generated assembly name: " + cr.CompiledAssembly.FullName))
        If cr.PathToAssembly Is Nothing Then
            Console.WriteLine("The assembly has been generated in memory.")
        Else
            Console.WriteLine(("Path to assembly: " + cr.PathToAssembly))
        End If
        ' Display temporary files information.
        If Not cr.TempFiles.KeepFiles Then
            Console.WriteLine("Temporary build files were deleted.")
        Else
            Console.WriteLine("Temporary build files were not deleted.")
            ' Display a list of the temporary build files
            Dim enu As IEnumerator = cr.TempFiles.GetEnumerator()
            Dim i As Integer
            i = 0
            While enu.MoveNext()
                Console.WriteLine(("TempFile " + i.ToString() + ": " + CStr(enu.Current)))
                i += 1
            End While
        End If
    End If
End Sub
注解
此类包含有关接口实现编译结果的 ICodeCompiler 以下信息:
- 属性 CompiledAssembly 指示已编译的程序集。 
- 属性 Evidence 指示程序集的安全证据。 
- 属性 PathToAssembly 指示已编译程序集的路径(如果它不是仅在内存中生成的)。 
- 属性 Errors 指示任何编译器错误和警告。 
- 属性 Output 包含编译器输出消息。 
- 属性 NativeCompilerReturnValue 指示编译器返回的结果代码值。 
- 属性 TempFiles 指示编译和链接期间生成的临时文件。 
注意
此类包含适用于所有成员的类级别的继承要求。 SecurityException当派生类没有完全信任权限时,将引发 。 有关继承需求的详细信息,请参阅 继承需求。
构造函数
| CompilerResults(TempFileCollection) | 初始化使用指定临时文件的 CompilerResults 类的新实例。 | 
属性
| CompiledAssembly | 获取或设置已编译的程序集。 | 
| Errors | 获取编译器错误和警告的集合。 | 
| Evidence | 
				已过时.
			 指示证据对象,该对象表示编译的程序集的安全策略权限。 | 
| NativeCompilerReturnValue | 获取或设置编译器的返回值。 | 
| Output | 获取编译器输出消息。 | 
| PathToAssembly | 获取或设置已编译程序集的路径。 | 
| TempFiles | 获取或设置要使用的临时文件集合。 | 
方法
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |