issue in OnAppearing() when calling async method, in realse mode , working fine in debug mode

Ashutosh Mehere 0 Reputation points
2024-05-03T13:41:37.7333333+00:00

//exception UserProfileData is null in resale mode , working fine in debug mode

protected override async void OnAppearing()

{

 try

 {

     base.OnAppearing();

     UserProfileData ??= new UserProfileData();

     if (UserProfileData.IsDataLoaded)

         return;

     IndicatorHome.IsVisible = true;

     HomePageContent.IsEnabled = false;

     UserProfileData = await _homeService.GetUserDetails();

     LabelUserName.Text = UserProfileData.Name;

     UserProfile.ImageSource = UserProfileData.ImageSource;

     DashBoardResponse = await _homeService.GetHomeScreenInfoAsync();

     RecentTransactionList.ItemsSource = await _homeService.GetRecentTransactionsTaskAsync();

     UserProfileData.IsDataLoaded = true;

     BindingContext = DashBoardResponse;

     IndicatorHome.IsVisible = false;

     HomePageContent.IsEnabled = true;

 }

 catch (Exception ex)

 {

     await DisplayAlert("Exception raised Home appearing",

         UserProfileData == null ? "UserProfileData is null" : ex.ToString(), "OK");

 }
``` }
Developer technologies .NET .NET MAUI
{count} votes

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.