Skip to content

Clarify StartupObject documentation: when it's needed and qualification requirements #47726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/csharp/language-reference/compiler-options/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ You add any of these options in a `<PropertyGroup>` element in your `*.csproj` f

## MainEntryPoint or StartupObject

This option specifies the class that contains the entry point to the program, if more than one class contains a `Main` method.
This option specifies the class that contains the entry point to the program when your compilation includes more than one type with a `Main` method. When there's exactly one acceptable `Main` method in the project, this option is ignored.

```xml
<StartupObject>MyNamespace.Program</StartupObject>
Expand All @@ -68,7 +68,7 @@ or
<MainEntryPoint>MyNamespace.Program</MainEntryPoint>
```

Where `Program` is the type that contains the `Main` method. The provided class name must be fully qualified; it must include the full namespace containing the class, followed by the class name. For example, when the `Main` method is located inside the `Program` class in the `MyApplication.Core` namespace, the compiler option has to be `-main:MyApplication.Core.Program`. If your compilation includes more than one type with a [`Main`](../../fundamentals/program-structure/main-command-line.md) method, you can specify which type contains the `Main` method.
Where `Program` is the type that contains the `Main` method. When this option is required (multiple `Main` methods exist), the provided class name must be fully qualified; it must include the full namespace containing the class, followed by the class name. For example, when the `Main` method is located inside the `Program` class in the `MyApplication.Core` namespace, the compiler option has to be `-main:MyApplication.Core.Program`. If the class is in the global namespace, the fully qualified name is the same as the simple class name (for example, `Program` instead of `MyNamespace.Program`).

> [!NOTE]
> This option can't be used for a project that includes [top-level statements](../../fundamentals/program-structure/top-level-statements.md), even if that project contains one or more `Main` methods.
Expand Down
Loading