Welcome to Microsoft Q&A forum.
Have you tried to add/set <TargetFramework>net6.0</TargetFramework> in your project(.xxproj file)? Please try to update Visual Studio to the latest version, if you are not using the latest version of VS 2022 Enterprise.
Besides, will the .NET 6.0 be listed when you create a new project? Did you use any assembly which maybe depend on earlier version of .NET? If so please try to update the assembly. Please also try to clean your project cache(delete the hidden .vs folder) and rebuild your project(reinstall NuGet packages if possible).
Update1:
Please open VS Installer > Modify > switch to Individual components
tab > .NET
and make sure that .NET SDK
and .NET 6.0 Runtime (Long Term Support)
have been checked.
Remove the hidden .vs, bin and obj folders in your solution/project folder and then rebuild you project and restart VS to check if the error disappears.
Please try to repair Visual Studio from VS Installer > More > Repair and reset VS settings(run devenv /ResetSettings
in Developer Command Prompt for Visual Studio 2022) if above methods don’t work.
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.