79

I have migrated from Visual Studio 2008 to VS 2017.

I am getting this error when I try to run project with the green play button:

enter image description here

Obviously I have to select a valid startup item, but there are two pieces of information I need to do that:

  1. what are typical valid startup items that I can try to select?

  2. How do I select them?

I am a long time developer, but I am new to visual studio so please give me instructions based on terminology I can see on the screen.

5
  • I solution explorer open context menu over project you want to be a startup and chose "Set as startup project". But probably you don't have proper project since of some deprecations. Tell what project types you have in your solution Commented Dec 3, 2017 at 20:28
  • I do not have a project in my solution explorer view. I only have folders. So that is the clue... I need to create a project. How do I do that? Commented Dec 3, 2017 at 20:34
  • There is not .sln file. The closest thing I have is a web.config file. Commented Dec 3, 2017 at 20:37
  • Probably you do have it - try to switch between folder view to project view - there is a button on the solution explorer toolbox. if you actually don't have a project then if you were converting a website folder - instead you can try to create an empty solution and just add "Existing website" Commented Dec 3, 2017 at 20:39
  • Have you open the project file direct with VS or in VS with open? Commented Dec 4, 2017 at 13:23

7 Answers 7

96

It might be the case that you have opened your project using

File->Open->Folder

Use the right method to open your project using

File->Open->Project/Solution

or

File->Open->Website
4
  • 10
    what to do when that folder doesnt have a .sln file?
    – T.Todua
    Commented Feb 15, 2020 at 17:44
  • 1
    @T.Todua use the second instruction which is File->Open->Website. Commented Feb 16, 2020 at 20:59
  • 3
    There's no .sln file because the project is based on cmake. There's no website; it's just .cpp and .h files. This is no help.
    – UserX
    Commented Nov 14, 2022 at 22:41
  • 5
    why is this the accepted answer ? the answer should be this: File > New > Project From existing code...
    – darren
    Commented Mar 8, 2023 at 20:13
43
+50

File > New > Project From existing code. Select type of project > Next. Enter project name > Finish.

0
4

I went to File > Open > project/Solution and found the ".sln" file. I clicked on it and then pressed open and it worked for me. Just spent ages trying to figure this out!

Regards,

1
  • Charles, you might have a misspelling: should snl be sln? Commented Apr 7, 2019 at 21:52
4

Open Visual Studio ------------------

  1. Click File
  2. Click Open
  3. Open as Web Sites

Another method

  1. Click File
  2. Click Open
  3. Open as Project
1
  • Hello @iamkanaramyadev. Welcome to stack overflow. This answer was a copy paste from the accepted answer. I recommend you improve it and perhaps explain better when each case exists as a way to add value to the question. If you are unable to do that you might get downvoted and lose reputation. Commented Nov 30, 2020 at 6:05
1

I found this question after I did File → Open → Folder as well. However in my case it's not a website, all I have is a source file. I don't want to create a full solution.

Now that Visual Studio supports CMake (to some degree), easiest is to add a simple CMakeLists.txt file, like this:

project (theproject)
add_executable (thetarget source.cpp)

As soon as the folder contains this file, Set as Startup Item turns up as a menu item in the Solution Explorer!

1

I just selected open file and selected the sln file on the project and boom it worked.

1
  • Hi Suleiman, I voted you up to show you some new user love but your answer is the same as others so you would typically comment on the existing answer or vote it up. Keep up the work of contributing; we need more contributors. Commented Dec 9, 2023 at 0:14
-3

The only solution is that or this error:

please select a valid startup file is that repair your visual studio

double click on visual studio installer and then click on the More then repair your visual studio

1
  • This issue arise when visual studio not downloading properly. So the simple solution is that Commented Mar 2, 2022 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.