This documentation is archived and is not being maintained.

CodeEntryPointMethod Class

Represents the entry point method of an executable.

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

'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeEntryPointMethod _
	Inherits CodeMemberMethod
'Usage
Dim instance As CodeEntryPointMethod

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 Shared Function BuildHelloWorldGraph() As CodeCompileUnit
   ' Create a new CodeCompileUnit to contain the program graph 
   Dim CompileUnit As New CodeCompileUnit()

   ' Declare a new namespace object and name it 
   Dim Samples As 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 
   Dim Class1 As 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 
   Dim Start As New CodeEntryPointMethod()
   ' Create a new method invoke expression 
   Dim cs1 As New CodeMethodInvokeExpression(New CodeTypeReferenceExpression("System.Console"), "WriteLine", 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.Statements.Add(New CodeExpressionStatement(cs1))

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

   Return CompileUnit

End Function 'BuildHelloWorldGraph 		

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: