OutOfMemoryException on MobileCache.WriteDiffGram

2281
0
09-05-2012 10:53 PM
CiprianLazar
New Contributor III
Because of some problems with the synchronization with the server, in order to avoid losing data, I am trying to write the modifications from the mobile cache to a local file in the device before starting the synchronization process.
I am using this code
using (System.IO.FileStream DiffGramWriter =
                    new System.IO.FileStream(System.IO.Path.GetDirectoryName(
                        System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\DiffGram.bkp", 
                        System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
                {
                    //** Write the Diff Gram for all the layers to DiffGram.bkp
                    Global.MobileCache1.WriteDiffGram(DiffGramWriter);
                    //DiffGramWriter.Flush();
                    DiffGramWriter.Close();
                }

The code works fine for a small amount of added/modified features. But when that volume is bigger (for example 500 newly added features) I get an OutOfMemoryException at
la System.Xml.XmlCharType.InitInstance()
la System.Xml.XmlCharType.get_Instance()
la System.Xml.XmlTextWriter..ctor()
la System.Xml.XmlTextWriter..ctor()
la System.Data.DataSet.WriteXml()
la ESRI.ArcGIS.Mobile.MobileServices.MobileCache.WriteDiffGram()
........

Is there any way to make that method work for any volume of modifications in the cache?
0 Kudos
0 Replies