Trying to build an app to iOS, & to my surprise it seems code in a standard C# try-catch block hangs the build. Does try-catch work in an iOS build? I hope I can post code here properly (first time), but the offending code is:
try {
xmlDoc.LoadXml(xmlDocString);
try {
steering = float.Parse(xmlDoc.DocumentElement.Attributes["steering"].Value);
} catch {
steering = 0f;
}
} catch {
}
It hangs on the inner try catch block. I nested the try-catch blocks to isolate the problem. xmlDoc is an XmlDocument object that loads an XML string sent via a SendMessage (so the string is cast from type object). I understand an exception may occur because the XML string may not contain the attribute. But isn’t try-catch supposed to handle this kind of exception handling? Does Android build have the same issue?
Any info welcome & appreciated. Thanks.
Just curious, did you ever get this to work? I'm on iOS too, getting the same error with try { System.Convert.FromBase64CharArray(charArray, 0, charArray.Length); } catch //Also tried catch (System.FormatException) since that's the error it's throwing but no luck { }
– CrystalRain0329Unfortunately I can't test on iOS, and I know the clue of the problem is try catch, but as a side note, you can convert the inner one to: float steering = 0f; var attrSteering = xmlDoc.DocumentElement.Attributes["steering"]; if(attrSteering == null || !Single.TryParse(attrSteering.Value, out steering)) { steering = 0f; }
– ArkaneXI've also had this problem on iOS, and removing the try catch block fixed the error (and I did have Slow and Safe selected).
– boddole