I have an application made with C#
to display the menu of my university's university restaurant, which picks up the information by means of XML
. The application allows the individual consultation of each meal (breakfast, lunch and dinner). It happens that at random times of the day, when any of the queries are requested, an error occurs and the application closes abruptly. Checking with debug
, I noticed the following message appears:
Error
"'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1 ".
I am now using a block try/catch
to see if I can avoid the abrupt closing but I have not succeeded yet.
-
Could anyone help me give due treatment to this error?
-
How can I solve this problem, at least to avoid abrupt closure of the application?
My try / catch block for now did just that, to try to prevent it from closing. The LoadDataHoje () method is looping so that it executes and attempts to access the information.
catch (System.ArgumentException erro)
{
LoadDataHoje();
contador++;
if(contador == 5)
{
throw new ArgumentException();
MessageBox.Show("O servidor está retornando um erro, tente novamente daqui a pouco :/","Erro no servidor", MessageBoxButton.OK);
this.NavigationService.Navigate(new Uri("/Src/Pages/MainPage.xaml", UriKind.Relative));
}
}
I have now checked out the debug that when it falls into this exception, at the end it shows another error, as in the image below. Thank you.