I have this code block that uses the 'new' dictionary (Xojo.Core.Dictionary) vs the 'original' Dictionary and the try catch block doesn't trigger on exception:
App.Preferences is a Xojo.Core.Dictionary object
' if there is a preference value for the last viewed page panel, load it up and set the 'page' to that value Try If App.Preferences.Value("mainWindowTab") <> Nil Then ' make sure there's a a value If IsNumeric (App.Preferences.Value("mainWindowTab")) Then ' make sure it's a number Page.Value = App.Preferences.Value("mainWindowTab") ' use the value End If End If Catch err As KeyNotFoundException ' log the error ' on first run and other situations where the mainWindowTab entry isn't present, ' an exception would be expected. just log it. Easy.Log.Write (err.Message, "error", "", True, False) End Try
KeyNotFoundException doesn't seem to work for Xojo.Core.Dictionary.
I changed the first line to:
If App.Preferences.HasKey("mainWindowTab") = True
I don't understand why KeyNotFoundException isn't 'forwards compatible' with Xojo.Core.Dictionary, but then again, I might be doing it wrong..