Hello @Raihanudin Rafif ,
Welcome to Microsoft Q&A forum.
Please first confirm that .NET SDK
has been checked in VS Installer > Modify > Individual components > .NET > .NET SDK. If it isn’t checked, please check it and click Modify.
Please then create a new .NET based project and check if the same error appears, if the same error appears, please try following to narrow down this issue:
- Reboot your machine and restart VS.
- Repair Visual Studio from VS Installer > More > Repair.
- Reset VS settings(run Developer Command Prompt for Visual Studio 2022 > run
devenv /ResetSettings
).
If the same error doesn’t appear, then please try following:
- Right-click your project > Unload Project > confirm that the
<Project Sdk="Microsoft.NET.Sdk">
line exists > right-click your project again > Reload Project. Open VS Installer > Modify > Individual components > .NET > make sure that.NET SDK
has been checked, if not, check it and click Modify. - Remove the hidden .vs, bin and obj folders in your solution/project folder and rebuild your project in VS.
Please feel free to let us know if this issue disappears.
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.