I have this code in ASP.NET form:
bool cont = true;
int i = 0;
while (cont)
{
try
{
JToken token = tempJSON["temperature"]["tool" + i];
temperature.Add(JsonConvert.DeserializeObject<Structures.Temperature>(token.ToString()));
i++;
}
catch(NullReferenceException ex) { pokracovat = false; }
}
return new TemperatureAndState(temperature, state);
And after running code, program rais NullReferenceException inside try catch. How it is possible. I thought if exception is raised in try the program will call catch and program continue.
Error:
Can you help me please?