This project has moved and is read-only. For the latest updates, please go here.

IndexOutOfRange Exception on device only

Mar 19, 2011 at 7:58 AM

I tried to load my app onto my WP7 device and i get an index out of range exception when trying to lad items from the database


I get the exception on this line 


            var retVal = _typeMaster[typeIndex];


in the method GetTypeAtIndex in the class Wintellect.Sterling.IsolatedStorage.PathProvider


the Code that i use to load looks like this. I get the exception in the foreach loop

        private void _LoadItems()
            var savedItems = (from key in App.Database.Query<Item, Guid>()
                              select key.LazyValue.Value);

            foreach (var item in savedItems)
Any idea why this works for the emulator but not on the phone? Any idea how to fix the issue?

Mar 19, 2011 at 11:51 AM

You may have changed the models. The emulator wipes isolated storage under certain circumstances and starts with a fresh database. The phone will retain this. If you changed the schema, the serialized image is no longer valid and will produce the exception. You should uninstall the application completely from the phone first, then redeploy it and see if that works.

Mar 19, 2011 at 2:29 PM

ahh cool uninstalling fixed it. I think the very first time i deployed it there was some issue that i had to fix. i'll keep this in mind next time