CodeEntryPointMethod Class
Represents the entry point method of an executable.
For a list of all members of this type, see CodeEntryPointMethod Members.
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeMemberMethod
System.CodeDom.CodeEntryPointMethod
[Visual Basic] <Serializable> <ClassInterface(ClassInterfaceType.AutoDispatch)> <ComVisible(True)> Public Class CodeEntryPointMethod Inherits CodeMemberMethod [C#] [Serializable] [ClassInterface(ClassInterfaceType.AutoDispatch)] [ComVisible(true)] public class CodeEntryPointMethod : CodeMemberMethod [C++] [Serializable] [ClassInterface(ClassInterfaceType::AutoDispatch)] [ComVisible(true)] public __gc class CodeEntryPointMethod : public CodeMemberMethod [JScript] public Serializable ClassInterface(ClassInterfaceType.AutoDispatch) ComVisible(true) class CodeEntryPointMethod extends CodeMemberMethod
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
A CodeEntryPointMethod is a CodeMemberMethod that represents the entry point method of an executable.
Example
[Visual Basic, C#, C++] This example demonstrates using a CodeEntryPointMethod to indicate the method to start program execution at.
[Visual Basic] ' 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 [C#] // 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; [C++] // 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(S"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(S"System") ); // Declare a new type object and name it CodeTypeDeclaration* Class1 = new CodeTypeDeclaration(S"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 CodeExpression* temp[] = {new CodePrimitiveExpression(S"Hello World!")}; CodeMethodInvokeExpression* cs1 = new CodeMethodInvokeExpression( // Call the System.Console.WriteLine method new CodeTypeReferenceExpression(S"System.Console"), S"WriteLine", // Pass a primitive string parameter to the WriteLine method temp); // 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;
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.CodeDom
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
See Also
CodeEntryPointMethod Members | System.CodeDom Namespace | CodeMemberMethod