Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

CodeEntryPointMethod Class

Represents the entry point method of an executable.

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

[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeEntryPointMethod : CodeMemberMethod
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeEntryPointMethod extends CodeMemberMethod
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeEntryPointMethod extends CodeMemberMethod
Not applicable.

A CodeEntryPointMethod is a CodeMemberMethod that represents the entry point method of an executable.

This example demonstrates using a CodeEntryPointMethod to indicate the method to start program execution at.

// Builds a Hello World Program Graph using System.CodeDom objects
public static CodeCompileUnit BuildHelloWorldGraph()
{            
    // Create a new CodeCompileUnit to contain the program graph
    CodeCompileUnit CompileUnit = new CodeCompileUnit();

    // Declare a new namespace object and name it
    CodeNamespace Samples = new CodeNamespace("Samples");
    // Add the namespace object to the compile unit
    CompileUnit.Namespaces.Add( Samples );

    // Add a new namespace import for the System namespace
    Samples.Imports.Add( new CodeNamespaceImport("System") );            

    // Declare a new type object and name it
    CodeTypeDeclaration Class1 = new CodeTypeDeclaration("Class1");
    // Add the new type to the namespace object's type collection
    Samples.Types.Add(Class1);            

    // Declare a new code entry point method
    CodeEntryPointMethod Start = new CodeEntryPointMethod();
    // Create a new method invoke expression
    CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression( 
        // Call the System.Console.WriteLine method
        new CodeTypeReferenceExpression("System.Console"), "WriteLine", 
        // Pass a primitive string parameter to the WriteLine method
        new CodePrimitiveExpression("Hello World!") );
    // Add the new method code statement
    Start.Statements.Add(new CodeExpressionStatement(cs1));        

    // Add the code entry point method to the type's members collection
    Class1.Members.Add( Start );

    return CompileUnit;

// Builds a Hello World Program Graph using System.CodeDom objects
public static CodeCompileUnit BuildHelloWorldGraph()
{
    // Create a new CodeCompileUnit to contain the program graph
    CodeCompileUnit compileUnit = new CodeCompileUnit();
    // Declare a new namespace object and name it
    CodeNamespace samples = new CodeNamespace("Samples");
    // Add the namespace object to the compile unit
    compileUnit.get_Namespaces().Add(samples);
    // Add a new namespace import for the System namespace
    samples.get_Imports().Add(new CodeNamespaceImport("System"));
    // Declare a new type object and name it
    CodeTypeDeclaration class1 = new CodeTypeDeclaration("Class1");
    // Add the new type to the namespace object's type collection
    samples.get_Types().Add(class1);
    // Declare a new code entry point method
    CodeEntryPointMethod start = new CodeEntryPointMethod();
    // Create a new method invoke expression
    CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression(new 
        CodeTypeReferenceExpression("System.Console"),
        "WriteLine", new CodeExpression[] { new 
        CodePrimitiveExpression("Hello World!") });
    // Call the System.Console.WriteLine method
    // Pass a primitive string parameter to the WriteLine method
    // Add the new method code statement
    start.get_Statements().Add(new CodeExpressionStatement(cs1));
    // Add the code entry point method to the type's members collection
    class1.get_Members().Add(start);

    return compileUnit;

System.Object
   System.CodeDom.CodeObject
     System.CodeDom.CodeTypeMember
       System.CodeDom.CodeMemberMethod
        System.CodeDom.CodeEntryPointMethod
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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.