A Visual Studio extension to quickly switch startup class

Have you ever wanted to set multiple entry points in a C# project to quickly switch between different programs? Well, it's not so simple—that's why I developed a Visual Studio Extension to help with that. "Change Startup Object" is a lightweight extension that adds a new "Set as Startup Object" command to context menus. With it, you can easily change which class serves as the entry point of your project. This command is similar to "Set as Startup Project" but is designed for setting a class as an entry point at the project level, allowing multiple Main methods across different .cs files. How It Works When the command is executed, the selected class is set in the respective project as the . This is a compiler option that specifies the entry point of the application. Shortcut Use Alt+F5 to set the active file OR the selected file in Solution Explorer as the Startup Object. Use Cases When you don't want to create multiple projects just to have different entry points, such as small POCs and benchmarks using Console Applications. A quick solution for CS0017 that eliminates the need to compile with the /main option. Limitations Doesn't work with top-level statements, since there is a limitation of only one top-level file per application. The selected class must have a Main method. Download and install Get it in Visual Studio Marketplace. Run and install the VSIX file.

Apr 9, 2025 - 16:29
 0
A Visual Studio extension to quickly switch startup class

Have you ever wanted to set multiple entry points in a C# project to quickly switch between different programs? Well, it's not so simple—that's why I developed a Visual Studio Extension to help with that.

"Change Startup Object" is a lightweight extension that adds a new "Set as Startup Object" command to context menus. With it, you can easily change which class serves as the entry point of your project.

This command is similar to "Set as Startup Project" but is designed for setting a class as an entry point at the project level, allowing multiple Main methods across different .cs files.

How It Works

When the command is executed, the selected class is set in the respective project as the . This is a compiler option that specifies the entry point of the application.

Shortcut

Use Alt+F5 to set the active file OR the selected file in Solution Explorer as the Startup Object.

Use Cases

  • When you don't want to create multiple projects just to have different entry points, such as small POCs and benchmarks using Console Applications.
  • A quick solution for CS0017 that eliminates the need to compile with the /main option.

Limitations

  • Doesn't work with top-level statements, since there is a limitation of only one top-level file per application.
  • The selected class must have a Main method.

Download and install