NavigationStack has a problem with ScanPage
I have a problem with the scan in a Xamarin app. It's just difficult to explain. I have 4 pages in my app. My Scan is open with a button in the 4th page. When i used the scan the first time i have no problem. As Long as stay on the 4th page i have no problem i can do a lot of scan with no error. But when i use the button Go Back in my app and i go on the 3th page and after i return to the 4th page and i used the scan i have an error.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At this moment my navigationStack is equal to 0.
My method GoBack just do:
Navigation.PopAsync();
And the scanner bug when i scan my QRCode and i call SendPresenceAck()
private async Task SendPresenceAck(string paramA09) //, int? idPrestation)
int idParticipant;
if (!int.TryParse(paramA09, out idParticipant))
//await this.ShowAlert("Attention", "Problème de lecture du QR Code.");
await this.DisplayAlert("Attention", "Problème de lecture du QR Code.", "Cancel");
return;
// On appelle le WS pour signifier la présence
// On passe par validateService
// On prépare la validation de la présence
var validateService = new ValidatePresenceService(this.Token);
// On ajoute la ligne à valider
var validate = validateService.AddNewPresence(idParticipant, this.idPrestation, true);
// On déclenche l'envoi au WS (si besoin)
if (validate != null)
// On envoie uniquement en cas de connexion
if (!Global.GetSettingsBool(TypeSettings.IsHorsConnexion))
//await validateService.SendAll();
// Attention : si participant déjà enregistré : erreur 403
try
await validateService.Send(validate);
// await this.DisplayAlert("OK", "Le billet est validé.", "OK");
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (WebException ex)
HttpWebResponse objresponse = ex.Response as HttpWebResponse;
if (objresponse.StatusCode == HttpStatusCode.Forbidden)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 403 : le participant a déjà été enregistré aujourd'hui
// Message d'erreur
// await this.DisplayAlert("Attention", "Le billet a déjà été enregistré, le numéro du billet a déjà été scanné auparavant.", "OK");
// return;
else if (objresponse.StatusCode == HttpStatusCode.NotFound)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 404 : billet non valide
// await this.DisplayAlert("Attention", "Le billet n'est pas valide.", "Cancel");
//return;
else if (objresponse.StatusCode == HttpStatusCode.Unauthorized)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (Exception e)
// Erreur
await this.DisplayAlert("Attention", e.Message, "Cancel");
return;
else
// Hors connexion : on vérifie juste si l'utilisateur n'est pas déjà présent dans la table SQL
// Attention : si pas de prestation : on a le droit d'enregistrer plusieurs fois la présence
// Si il y a une prestation, en revanche, on doit vérifier qu'il n'est pas déjà inscrit
if (validate.IdPrestation.HasValue &&
validateService.IsInscriptionAlreadyRecorded(validate))
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// Déjà trouvé : message d'erreur
// await this.DisplayAlert("Attention", "Le participant a déjà été enregistré.", "OK");
//
// return;
else
// Pb à l'insertion des données ??
return;
The exception is on the line:
popupLoginView.IsVisible = true;
Sorry it's very hard to explain and i'm not english so i hope somebody understand and help me.
Thanks.
c# xamarin stack qr-code
add a comment |
I have a problem with the scan in a Xamarin app. It's just difficult to explain. I have 4 pages in my app. My Scan is open with a button in the 4th page. When i used the scan the first time i have no problem. As Long as stay on the 4th page i have no problem i can do a lot of scan with no error. But when i use the button Go Back in my app and i go on the 3th page and after i return to the 4th page and i used the scan i have an error.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At this moment my navigationStack is equal to 0.
My method GoBack just do:
Navigation.PopAsync();
And the scanner bug when i scan my QRCode and i call SendPresenceAck()
private async Task SendPresenceAck(string paramA09) //, int? idPrestation)
int idParticipant;
if (!int.TryParse(paramA09, out idParticipant))
//await this.ShowAlert("Attention", "Problème de lecture du QR Code.");
await this.DisplayAlert("Attention", "Problème de lecture du QR Code.", "Cancel");
return;
// On appelle le WS pour signifier la présence
// On passe par validateService
// On prépare la validation de la présence
var validateService = new ValidatePresenceService(this.Token);
// On ajoute la ligne à valider
var validate = validateService.AddNewPresence(idParticipant, this.idPrestation, true);
// On déclenche l'envoi au WS (si besoin)
if (validate != null)
// On envoie uniquement en cas de connexion
if (!Global.GetSettingsBool(TypeSettings.IsHorsConnexion))
//await validateService.SendAll();
// Attention : si participant déjà enregistré : erreur 403
try
await validateService.Send(validate);
// await this.DisplayAlert("OK", "Le billet est validé.", "OK");
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (WebException ex)
HttpWebResponse objresponse = ex.Response as HttpWebResponse;
if (objresponse.StatusCode == HttpStatusCode.Forbidden)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 403 : le participant a déjà été enregistré aujourd'hui
// Message d'erreur
// await this.DisplayAlert("Attention", "Le billet a déjà été enregistré, le numéro du billet a déjà été scanné auparavant.", "OK");
// return;
else if (objresponse.StatusCode == HttpStatusCode.NotFound)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 404 : billet non valide
// await this.DisplayAlert("Attention", "Le billet n'est pas valide.", "Cancel");
//return;
else if (objresponse.StatusCode == HttpStatusCode.Unauthorized)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (Exception e)
// Erreur
await this.DisplayAlert("Attention", e.Message, "Cancel");
return;
else
// Hors connexion : on vérifie juste si l'utilisateur n'est pas déjà présent dans la table SQL
// Attention : si pas de prestation : on a le droit d'enregistrer plusieurs fois la présence
// Si il y a une prestation, en revanche, on doit vérifier qu'il n'est pas déjà inscrit
if (validate.IdPrestation.HasValue &&
validateService.IsInscriptionAlreadyRecorded(validate))
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// Déjà trouvé : message d'erreur
// await this.DisplayAlert("Attention", "Le participant a déjà été enregistré.", "OK");
//
// return;
else
// Pb à l'insertion des données ??
return;
The exception is on the line:
popupLoginView.IsVisible = true;
Sorry it's very hard to explain and i'm not english so i hope somebody understand and help me.
Thanks.
c# xamarin stack qr-code
On which line does the Exception get thrown?
– MindSwipe
Nov 12 '18 at 14:50
Seems you were trying to index an object with a value that was not valid. Check your code about list in your project when you scan.
– Jack Hua - MSFT
Nov 15 '18 at 8:11
The only list i have is my NavigationStack whose become empty just during the scan.
– Kanok
Nov 22 '18 at 10:06
add a comment |
I have a problem with the scan in a Xamarin app. It's just difficult to explain. I have 4 pages in my app. My Scan is open with a button in the 4th page. When i used the scan the first time i have no problem. As Long as stay on the 4th page i have no problem i can do a lot of scan with no error. But when i use the button Go Back in my app and i go on the 3th page and after i return to the 4th page and i used the scan i have an error.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At this moment my navigationStack is equal to 0.
My method GoBack just do:
Navigation.PopAsync();
And the scanner bug when i scan my QRCode and i call SendPresenceAck()
private async Task SendPresenceAck(string paramA09) //, int? idPrestation)
int idParticipant;
if (!int.TryParse(paramA09, out idParticipant))
//await this.ShowAlert("Attention", "Problème de lecture du QR Code.");
await this.DisplayAlert("Attention", "Problème de lecture du QR Code.", "Cancel");
return;
// On appelle le WS pour signifier la présence
// On passe par validateService
// On prépare la validation de la présence
var validateService = new ValidatePresenceService(this.Token);
// On ajoute la ligne à valider
var validate = validateService.AddNewPresence(idParticipant, this.idPrestation, true);
// On déclenche l'envoi au WS (si besoin)
if (validate != null)
// On envoie uniquement en cas de connexion
if (!Global.GetSettingsBool(TypeSettings.IsHorsConnexion))
//await validateService.SendAll();
// Attention : si participant déjà enregistré : erreur 403
try
await validateService.Send(validate);
// await this.DisplayAlert("OK", "Le billet est validé.", "OK");
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (WebException ex)
HttpWebResponse objresponse = ex.Response as HttpWebResponse;
if (objresponse.StatusCode == HttpStatusCode.Forbidden)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 403 : le participant a déjà été enregistré aujourd'hui
// Message d'erreur
// await this.DisplayAlert("Attention", "Le billet a déjà été enregistré, le numéro du billet a déjà été scanné auparavant.", "OK");
// return;
else if (objresponse.StatusCode == HttpStatusCode.NotFound)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 404 : billet non valide
// await this.DisplayAlert("Attention", "Le billet n'est pas valide.", "Cancel");
//return;
else if (objresponse.StatusCode == HttpStatusCode.Unauthorized)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (Exception e)
// Erreur
await this.DisplayAlert("Attention", e.Message, "Cancel");
return;
else
// Hors connexion : on vérifie juste si l'utilisateur n'est pas déjà présent dans la table SQL
// Attention : si pas de prestation : on a le droit d'enregistrer plusieurs fois la présence
// Si il y a une prestation, en revanche, on doit vérifier qu'il n'est pas déjà inscrit
if (validate.IdPrestation.HasValue &&
validateService.IsInscriptionAlreadyRecorded(validate))
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// Déjà trouvé : message d'erreur
// await this.DisplayAlert("Attention", "Le participant a déjà été enregistré.", "OK");
//
// return;
else
// Pb à l'insertion des données ??
return;
The exception is on the line:
popupLoginView.IsVisible = true;
Sorry it's very hard to explain and i'm not english so i hope somebody understand and help me.
Thanks.
c# xamarin stack qr-code
I have a problem with the scan in a Xamarin app. It's just difficult to explain. I have 4 pages in my app. My Scan is open with a button in the 4th page. When i used the scan the first time i have no problem. As Long as stay on the 4th page i have no problem i can do a lot of scan with no error. But when i use the button Go Back in my app and i go on the 3th page and after i return to the 4th page and i used the scan i have an error.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At this moment my navigationStack is equal to 0.
My method GoBack just do:
Navigation.PopAsync();
And the scanner bug when i scan my QRCode and i call SendPresenceAck()
private async Task SendPresenceAck(string paramA09) //, int? idPrestation)
int idParticipant;
if (!int.TryParse(paramA09, out idParticipant))
//await this.ShowAlert("Attention", "Problème de lecture du QR Code.");
await this.DisplayAlert("Attention", "Problème de lecture du QR Code.", "Cancel");
return;
// On appelle le WS pour signifier la présence
// On passe par validateService
// On prépare la validation de la présence
var validateService = new ValidatePresenceService(this.Token);
// On ajoute la ligne à valider
var validate = validateService.AddNewPresence(idParticipant, this.idPrestation, true);
// On déclenche l'envoi au WS (si besoin)
if (validate != null)
// On envoie uniquement en cas de connexion
if (!Global.GetSettingsBool(TypeSettings.IsHorsConnexion))
//await validateService.SendAll();
// Attention : si participant déjà enregistré : erreur 403
try
await validateService.Send(validate);
// await this.DisplayAlert("OK", "Le billet est validé.", "OK");
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (WebException ex)
HttpWebResponse objresponse = ex.Response as HttpWebResponse;
if (objresponse.StatusCode == HttpStatusCode.Forbidden)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 403 : le participant a déjà été enregistré aujourd'hui
// Message d'erreur
// await this.DisplayAlert("Attention", "Le billet a déjà été enregistré, le numéro du billet a déjà été scanné auparavant.", "OK");
// return;
else if (objresponse.StatusCode == HttpStatusCode.NotFound)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 404 : billet non valide
// await this.DisplayAlert("Attention", "Le billet n'est pas valide.", "Cancel");
//return;
else if (objresponse.StatusCode == HttpStatusCode.Unauthorized)
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// 401 : impossible d'identifier le numéro du billet
// await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");
// return;
catch (Exception e)
// Erreur
await this.DisplayAlert("Attention", e.Message, "Cancel");
return;
else
// Hors connexion : on vérifie juste si l'utilisateur n'est pas déjà présent dans la table SQL
// Attention : si pas de prestation : on a le droit d'enregistrer plusieurs fois la présence
// Si il y a une prestation, en revanche, on doit vérifier qu'il n'est pas déjà inscrit
if (validate.IdPrestation.HasValue &&
validateService.IsInscriptionAlreadyRecorded(validate))
popupLoginView.IsVisible = true;
//Gestion du premier stack et du bouton
StckSLayout.BackgroundColor = Color.FromHex("#DD5500");
ImageBack.BackgroundColor = Color.White;
//BoxSEmpty.BackgroundColor= Color.FromHex("#DD5500");
button.BackgroundColor = Color.FromHex("#DD5500");
button.Text = "Blabla";
//BoxSEmpty.Clicked += boutonSortir;
button.Clicked += async (sender, e) =>
// Ouverture du scan
await BtnScanClicked(sender, e);
;
//Gestion à partir du deuxième stack
StckSLayoutMiddle.BackgroundColor = Color.FromHex("#DD7700");
LbldAlert.BackgroundColor = Color.FromHex("#641914");
LbldAlert.Text = "ALERTE";
LblSEnd.BackgroundColor = Color.FromHex("#641914");
LblSEnd.Text = "Blabla";
// Déjà trouvé : message d'erreur
// await this.DisplayAlert("Attention", "Le participant a déjà été enregistré.", "OK");
//
// return;
else
// Pb à l'insertion des données ??
return;
The exception is on the line:
popupLoginView.IsVisible = true;
Sorry it's very hard to explain and i'm not english so i hope somebody understand and help me.
Thanks.
c# xamarin stack qr-code
c# xamarin stack qr-code
edited Nov 12 '18 at 14:57
Kanok
asked Nov 12 '18 at 14:45
KanokKanok
33
33
On which line does the Exception get thrown?
– MindSwipe
Nov 12 '18 at 14:50
Seems you were trying to index an object with a value that was not valid. Check your code about list in your project when you scan.
– Jack Hua - MSFT
Nov 15 '18 at 8:11
The only list i have is my NavigationStack whose become empty just during the scan.
– Kanok
Nov 22 '18 at 10:06
add a comment |
On which line does the Exception get thrown?
– MindSwipe
Nov 12 '18 at 14:50
Seems you were trying to index an object with a value that was not valid. Check your code about list in your project when you scan.
– Jack Hua - MSFT
Nov 15 '18 at 8:11
The only list i have is my NavigationStack whose become empty just during the scan.
– Kanok
Nov 22 '18 at 10:06
On which line does the Exception get thrown?
– MindSwipe
Nov 12 '18 at 14:50
On which line does the Exception get thrown?
– MindSwipe
Nov 12 '18 at 14:50
Seems you were trying to index an object with a value that was not valid. Check your code about list in your project when you scan.
– Jack Hua - MSFT
Nov 15 '18 at 8:11
Seems you were trying to index an object with a value that was not valid. Check your code about list in your project when you scan.
– Jack Hua - MSFT
Nov 15 '18 at 8:11
The only list i have is my NavigationStack whose become empty just during the scan.
– Kanok
Nov 22 '18 at 10:06
The only list i have is my NavigationStack whose become empty just during the scan.
– Kanok
Nov 22 '18 at 10:06
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264565%2fnavigationstack-has-a-problem-with-scanpage%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264565%2fnavigationstack-has-a-problem-with-scanpage%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
On which line does the Exception get thrown?
– MindSwipe
Nov 12 '18 at 14:50
Seems you were trying to index an object with a value that was not valid. Check your code about list in your project when you scan.
– Jack Hua - MSFT
Nov 15 '18 at 8:11
The only list i have is my NavigationStack whose become empty just during the scan.
– Kanok
Nov 22 '18 at 10:06