Can't run my code, VS asks me to attach to process

Idan-Hi Levayev 0 Reputation points
2023-02-11T23:10:54.37+00:00

I started learning code in my free time, the code was working and running perfectly, saved the code as a .cs file (the only option I saw)

Re-opend it later and tried to run it again, keeps asking me to attach to process,

When I open a new project and paste all of the code it runs again.

  • My friend just downloaded VS and right from the beginning it asks he to attach to process, he could not run a code once, nothing worked for him.
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,448 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,341 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 33,646 Reputation points Microsoft External Staff
    2023-02-13T06:28:02.4+00:00

    Hello @Idan-Hi Levayev ,

    Welcome to Microsoft Q&A forum.

    You need to create a C# project(for example C# Console application project) and write C# codes then run(build and run) it in VS, after that it will run. You can’t run a single .cs file in VS, so you saw "attach to process" instead of "Run".

    See this document: Start from a project for more details.

    Feel free to contact us.

    Best Regards,

    Tianyu


    If the answer is the right solution, 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.

    0 comments No comments

Your answer

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