Get index out of range exception

Mar 18, 2011 at 11:03 AM
Edited Mar 18, 2011 at 11:04 AM


Using the database, when application ends with some exception or some other reason, upon opening the application I activate the engine I get exception and just crashes.

anything i m missing, pls help?. I added _deactiveengine() in unhandled exception block too




Mar 18, 2011 at 1:02 PM

Are you flushing after saves? Typically that is the major issue, either a flush not happening, or a complex save in the middle. Unfortunately, we currently don't have transactional saves but that is coming in a future version.

Mar 21, 2011 at 10:28 AM


oh yeah i was not doing flush, will test more with flush added


Mar 22, 2011 at 10:30 AM
Edited Mar 22, 2011 at 11:16 AM


I am downloading some 1000s msgs from server and saving to database.

I flush each time i download 100 msgs, after each 100 records save I flush.


During this process,if application is tombstoned, database save leads to crash and I get that above exception. Any way to handle this?

Just catch exception block and flush in exception handle?

(-Once it crashes while saving , no way to flush, even that crashes)


Mar 22, 2011 at 11:30 AM

Yes, you should always flush before tombstone.

Mar 22, 2011 at 12:09 PM
Edited Mar 22, 2011 at 12:10 PM

That crash was due to I had _DeactiveEngine in Deactivated  and my thread was still trying to save the records which keeps running during tombstoning for complete 10seconds ... since in deactivate SterDabatase becomes null, save crashes ............. this is the Cause..........


   private void Application_Deactivated(object sender, DeactivatedEventArgs e)


Now I Flush on Deactivated and handled null check for saving like below

 if (App.SterDatabase != null)


Mar 22, 2011 at 12:12 PM

So during Tombstoning case, always we should flush.


Is there any way to know , Application is entering Tombstoning, so that I can stop saving record thread?

Mar 22, 2011 at 12:41 PM

Tombstoning will trigger certain calls in the code-behind for controls. Easiest way is just to capture the event and perhaps publish an event aggregator message.

Take a look here: