Export (0) Print
Expand All

CompilerResults Class

Represents the results of compilation that are returned from a compiler.

Namespace: System.CodeDom.Compiler
Assembly: System (in system.dll)

[SerializableAttribute] 
public class CompilerResults
/** @attribute SerializableAttribute() */ 
public class CompilerResults
SerializableAttribute 
public class CompilerResults
Not applicable.

This class contains the following information about the results of a compilation by an ICodeCompiler interface implementation:

  • The CompiledAssembly property indicates the compiled assembly.

  • The Evidence property indicates the security evidence for the assembly.

  • The PathToAssembly property indicates the path to the compiled assembly, if it was not generated only in memory.

  • The Errors property indicates any compiler errors and warnings.

  • The Output property contains the compiler output messages.

  • The NativeCompilerReturnValue property indicates result code value returned by the compiler.

  • The TempFiles property indicates the temporary files generated during compilation and linking.

NoteNote:

This class contains an inheritance demand at the class level that applies to all members. A SecurityException is thrown when the derived class does not have full-trust permission. For details about inheritance demands, see Inheritance Demands.

// 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 );                  
        }
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft