I cannot run C# console program in Visual Studio.

Trijit Reet Adhikary 0 Reputation points
2023-08-12T18:36:49.2133333+00:00

I cannot run C# console program in Visual Studio. Instead of the run button, I am getting Attach button. I tried to set startup project but did not get any project in the pulldown menu. I reinstalled .NET SDK but when I ran dotnet --info on the command prompt it showed no SDK installed. I added the following paths also in the "edit Environment variables" - C:\Program Files (x86)\dotnet\dotnet.exe;C:\Program Files\dotnet\dotnet.exe;

but after all these problem still exists.

C:\>dotnet --info

Host:
  Version:      7.0.10
  Architecture: x86
  Commit:       a6dbb800a4

.NET SDKs installed:
  No SDKs were found.
Developer technologies | .NET | Other
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,156 Reputation points Microsoft External Staff
    2023-08-14T06:58:59.8+00:00

    Hi @Trijit Reet Adhikary

    Welcome to Microsoft Q&A! 

    Are you using VS2022? What is your project’s target framework? Does it occur in new created C# console project? 

    Please close all running VS instances and open the Visual Studio Installer > Modify > make sure you have the .NET desktop development workload installed. 

    Then, edit your System Environment variables and add this one to Path: C:\Program Files\dotnet, not C:\Porgram Files (x86)\dotnet

    After deleting, please restart your computer and launch the VS to check that it works properly. 

    Sincerely,

    Anna


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

     

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.