Getting "Invalid file or corrupted file" Exception when Opening Map Cache after Sync

Discussion created by MakiG007 on Apr 5, 2012
Latest reply on May 2, 2012 by spruce23
Ok, So I have this Windows Mobile 6 ArcGIS Mobile 10 SDK application that I can get to run wonderfully as long as I have created a mobile cache and physically placed it onto the device.

But whenever I try to use a MobileServiceConnection, MobileCache, and MobileCacheSyncAgent to Synchronize my map with the MapServer on my ArcGIS Server I get a "Invalid file or corrupted file" exception as soon as I try to open the MobileCache.

I checked the ArcGIS Server logs and it appears to be receiving the request, and processing it correctly:
Level Message         Time   Configuration
INFO3 Server Context released.      2012-03-23 17:40:37 Facilities.MapServer 
INFO2 Binary request successfully processed. Response size is 2136 bytes. 2012-03-23 17:40:37 Facilities.MapServer 
DEBUG MobileSync: Get Schema [elapsed time = 0.001189 seconds].  2012-03-23 17:40:37 Facilities.MapServer 
DEBUG Schema Checksum 2197403820.      2012-03-23 17:40:37 Facilities.MapServer 
INFO2 Binary request received. Request size is 5 bytes.   2012-03-23 17:40:37 Facilities.MapServer 
INFO3 Server Context created.       2012-03-23 17:40:37 Facilities.MapServer

Here is my code:
                if (!Utility.CheckURLConnection(AppProps.MobileMapServiceURL + "?wsdl"))
                    MessageBox.Show("Not able to connect to map server.");
                mobileMapServiceCache.StoragePath = mobileMapServiceCachePath;
                mobileMapServiceConn.Url = AppProps.MobileMapServiceURL;
                MobileCacheSyncAgent mobileSync = new MobileCacheSyncAgent(mobileMapServiceCache, mobileMapServiceConn);
                if (mobileSync.IsValid)
                    //mobileSync.StateChanged += new EventHandler(mobileSync_StateChanged);
                    //mobileSync.ProgressChanged += new EventHandler<MobileCacheSyncAgentProgressEventArgs>(mobileSync_ProgressChanged);
                    SyncResults mobileResults = mobileSync.Synchronize();
            catch (Exception ex)
                MessageBox.Show("Cannot synchronize with the mobile map service: " + ex.Message);

I even tried adding event handlers to the MobileCacheSyncAgent ... but they were never called ...

The MessageBox right before the mobileMapServiceCache.Open(); call always return 0 ...

back in 9.3.1 all we had to do was use a MobileService ... am I doing something wrong? Please help!

Furthermore, I have tried the following with no success

  •     downloading and installing the latest build of ArcGIS Mobile (build 2550)

  •     Enabling Feature Access on the MapService

  •     changing the map service from pooled to non-pooled

  •     using a different/simple Map Service with only 1 featurelayer

  •     breaking the synchronize process down to synchronizing each FeatureLayer individually with the FeatureLayerSyncAgent

  •     Setting the SynchronizationDirection to SyncDirection.DownloadOnly

  •     changing the WebClientProtocolType to WebClientProtocolType.SoapWebService

  •     using DownloadExtent instead of Synchronize

  •     compiled the application in Release (instead of debug)

  •     tried it on a different Emulator

  •     tried it on an actual device

I have also discovered that in the MobileCache directory, the only file that is getting updated is the MobileCache.db-journal.

Deleting the contents of the db-journal file (or simply deleting the file) allows the application to open the MapCache correctly. However, it does not have any of the new data from the map service.

Somehow, the DownloadExtent/Synchronize process correctly makes a request to ArcGIS Server, gets a response back and then writes some junk in the .db-journal file, thus corrupting my local map cache and not actually getting any of the new data.

maybe someone can explain how the process is supposed to work and how the files in the MobileCache directory are supposed to be updated to help me narrow down the problem.

In case you are curious ... here is one example of what the db-journal is populating with:
�?�?ù ¡c�?   ï�?e�?�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               /
   �? �?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ' #2sde.DEFAULT"  �?  �?þÿÿÿ�?ê�?ÿï�?e�?�   SQLite format 3   @     3            �?                                                         <Á    ãûöñìçâÝ�?�?�?�?�?¿ºµ°«¦¡�?�??�??�?�?~ytoje`[VQLGB=83-'! ý÷ñëå�?�?�?Í�?Á                                                                                                                                          #GGEtablelayer0_current_spatial_parentlayer0_current_spatial_parentCREATE TABLE "layer0_current_spatial_parent"(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)EE9tablelayer0_current_spatial_rowidlayer0_current_spatial_rowidCREATE TABLE "layer0_current_spatial_rowid"(rowid INTEGER PRIMARY KEY, nodeno INTEGER)CC/   �?A   �?>   �?:   Ё5   �?1   �?-   �?(   ¿&   ½"   ¸    µ   °   ®   ©   ¦   ¡   Ÿ   š   �??   �??   {   �?�y   �?t   �?r   �?�m   {k   yf   te   r`   p_   k\   iY   dX   bS   ]R   ZM   UK   SG   NE   K@   F>   C9   >7   <2   71   5,   3+   .(   ,%   '$   %                       

I originally posted this over in the ArcGIS Mobile Forum, but was unable to get any help :( ... not sure if this forum will get any more attention or not but I figured it was worth a shot :)

Thanks in advance!