How can I choose startup object in Visual Studio?

Viewed 16212

There are three cpp files and if I start debug, an error message appears: "Choose startup object."

So I clicked 'Current document' but nothing has changed.

Some peoply say do right click on solution and go to 'properties', but I can't find the 'properties' menu... How can I choose startup object?

5 Answers

With Visual Studio IDE 2019 on MAC, legacy method of setting up a startup object for C# project has been changed.

If you are C# beginner and have built console project for learning core concept, then there might be a situation, where you may write main() method in each .cs code file to evaluate concepts. so here are below steps to be followed in order to change (.cs) startup object for debugging your intended .cs file using visual studio IDE 2019 on MAC :

  1. Go to project solution hierarchy
  2. Select (.cs) file, which set to be startup object.
  3. press Control+leftClick from keyboard and select 'Properties' option.
  4. In 'Properties' windows, select 'Build action' attribute and set its value to 'complie'
  5. and change same value to 'none' for other .cs files, which are not to be set startup object.

As in result, build will be successful and your program will run in command line interface.

First, the question mentions the startup object, not project.

In my Visual Studio 2022 on Windows, my WPF project's properties contain a field "Startup object" which can be either (Not set) or the App.xaml(.cs). I wanted to control execution more than that, by changing the project to a console application and setting Program.cs as the startup object.

I managed this by editing the project XML. I had this line:

<StartupObject></StartupObject>

And now I have this one:

<StartupObject>Wpf.Program</StartupObject>

After this change, I see Wpf.Program as the selected option in the project's properties.

I found this answer here.

This happened to me when I tried to write c++ on a "visual studio solution". Make sure to select (or install and select) the correct project type when creating it.

Related