I have a .NET MAUI project that shows these 3 compile errors (that shouldn't occur), but it compiles and runs successfully anyway:
Here is the source of my MainPage.xaml.cs
:
using Android.Media;
namespace MovieDoo;
public partial class MainPage : ContentPage
{
MediaPlayer _player;
string _userID = "777";
public MainPage()
{
InitializeComponent();
_player = new MediaPlayer();
}
private void OnAudioClicked(object sender, EventArgs e) {
_player.SetDataSource("https://samplelib.com/lib/preview/mp3/sample-6s.mp3");
_player.Prepare();
_player.Start();
}
private void getQuestion() {
string encryptedUserID = Utilities.Encrypt(_userID);
}
private void OnSubmitClicked(object sender, EventArgs e) {
string movieTitle = txtMovieTitle.Text;
if(!string.IsNullOrEmpty(movieTitle)) {
if(txtMovieTitle.Text.Trim().ToLower().Contains("casablanca")) {
toggleCorrectIncorrect(true);
} else {
toggleCorrectIncorrect(false);
}
} else {
toggleCorrectIncorrect(false);
}
}
private void toggleCorrectIncorrect(bool isCorrect) {
if(isCorrect) {
lblIncorrect.IsVisible = false;
lblCorrect.IsVisible = true;
} else {
lblCorrect.IsVisible = false;
lblIncorrect.IsVisible = true;
}
}
}
As you can see, the little sample app loads in the Android emulator and runs as expected:
I have been using Visual Studio for many years, but until I started building this little MAUI project, I have never before seen phantom compile errors that don't prevent the app from running as expected. Additionally, sometimes these errors remain in the build output window, and sometimes they flash for a moment and then disappear.
What is causing these phantom compile errors and how can I get them to go away permanently?