1
I have an app made on C#
to show the menu of my university’s university restaurant, which picks up the information through a XML
. The app allows individual consultation of each meal (breakfast, lunch and dinner). It happens that at random times of the day, when one of the queries is requested, an error occurs and the application closes abruptly. Checking with a debug
, I noticed the following message:
Error
" ' ', hexadecimal value 0x1F, is an invalid Character. Line 1, position 1".
I’m using a block now try/catch
to see if I can avoid sudden closure, but I haven’t been able to yet.
Could someone help me give due treatment to this mistake?
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 like a loop, so that it runs and tries 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 checked now by debug that when it falls in this exception, at the end it shows another error, as in the image below. Thank you.
Place the error and code where the error is being pointed.
– Vinicius Zaramella
Hello you could include the code snippet inserted in the
try catch
? , details about your code will help us solve your problem, just edit the question.– stringnome
Possibly an enconding problem? I believe you have q format your ASCII result. Or modify your parser settings to read utf-8.
– Vinicius Zaramella
I wanted to at least prevent the application to close abruptly, but even with this catch he is closing.
– Robledo Gomes