public async static Task<bool> CheckForPreviousException()
        {
            try
            {
                errormessage = null;

                var container = ApplicationData.Current.LocalSettings.Containers;
                var exceptionValues = container[SettingName].Values;

                string exceptionText = null;
                if (exceptionValues.ContainsKey(ExceptionStringKey))
                {
                    exceptionText = exceptionValues[ExceptionStringKey] as string;
                    if (!string.IsNullOrEmpty(exceptionText))
                    {
                        errormessage = JsonConvert.DeserializeObject<ErrorMessageInfo>(exceptionText);
                    }
                    exceptionValues[ExceptionStringKey] = string.Empty;
                }

                if (errormessage != null)
                {
                    await ShowErrorMessageDialog();
                }
            }
            catch { }
            return true;
        }
 public static void HandleException(Exception ex, string extra = "")
 {
     try
     {
         errormessage = new ErrorMessageInfo()
         {
             UserMessage = string.IsNullOrEmpty(extra) ? "Unexpected error" : extra,
             Info = string.IsNullOrEmpty(ex.Message) ? "Error message" : ex.Message,
             Exception = ex.InnerException.ToString(),
             ExceptionDetail = ex.StackTrace
         };
         ApplicationData.Current.LocalSettings.CreateContainer(SettingName, ApplicationDataCreateDisposition.Always);
         var exceptionValues = ApplicationData.Current.LocalSettings.Containers[SettingName].Values;
         var jsonString = JsonConvert.SerializeObject(errormessage);
         exceptionValues[ExceptionStringKey] = jsonString;
     }
     catch { }
 }