Create project with console template using vs 2022 and it give errors Microsoft Visual Studio Community 2022 (64-bit) - Current

pxb pxb 0 Reputation points
2024-11-01T16:22:50.7966667+00:00

1.Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.9.0

2.>dotnet --version 8.0.201
3. I created project with console template, and the it give me errors, i delete it and try severl time.
it not work.
User's image

errors:
a) Severity Code Description Project File Line Suppression State Details

Error S1118 Add a 'protected' constructor or the 'static' keyword to the class declaration. ConsoleApp1 C:\Users\PC\Desktop\Test\cal\ConsoleApp1\ConsoleApp1\Program.cs 3 Active

b) Severity Code Description Project File Line Suppression State Details

Error CA1303 Method 'void Program.Main(string[] args)' passes a literal string as parameter 'value' of a call to 'void Console.WriteLine(string? value)'. Retrieve the following string(s) from a resource table instead: "Hello, World!". ConsoleApp1 C:\Users\PC\Desktop\Test\cal\ConsoleApp1\ConsoleApp1\Program.cs 7 Active

Developer technologies Visual Studio Other
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2024-11-04T03:06:28.7433333+00:00

    Hi @pxb pxb ,

    If you are using any extension, try to disable it temporarily and check if this issue persists.

    Open VS Installer and click More, Repair to repair VS.

    I notice that the color of the tab and some key words are changed on your side. I’m not sure if you changed some settings in VS or you are using any extensions. I suggest you also try to reset VS settings if possible(close VS, search and open Developer Command Prompt for VS 2022 in Windows Search box, run devenv /ResetSettings).  

    As the last resort, you may consider updating(17.9.0 => 17.11.5)/reinstalling VS.

    BTW, does this issue appear on other projects such as .NET Framework Console App C#, Windows Forms App…?

    Feel free to let us know the results.

    Happy coding!

    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.


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.