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

Get index out of range exception

Mar 18, 2011 at 12:03 PM
Edited Mar 18, 2011 at 12:04 PM


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 2: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 11:28 AM


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


Mar 22, 2011 at 11:30 AM
Edited Mar 22, 2011 at 12:16 PM


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 12:30 PM

Yes, you should always flush before tombstone.

Mar 22, 2011 at 1:09 PM
Edited Mar 22, 2011 at 1: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 1: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 1: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: