First of all, please update your VS version to the latest version. If you get the same issue?
If still have this issue, please close visual studio, find your project's folder, delete the bin and obj folders, then run visual studio with "run as administrator", open your project will you get the same error?
If you still have this error, please click the MainPage.xaml, check the build action if it is MauiXaml.
If you still have this issue, please share your current VS version.