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

1094
2
03-23-2012 03:21 PM
KevinBupp
New Contributor III
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
            try
            {
                if (!Utility.CheckURLConnection(AppProps.MobileMapServiceURL + "?wsdl"))
                {
                    MessageBox.Show("Not able to connect to map server.");
                }
                mobileMapServiceCache.StoragePath = mobileMapServiceCachePath;
                mobileMapServiceCache.DeleteCache();
                mobileMapServiceConn.Url = AppProps.MobileMapServiceURL;
                MobileCacheSyncAgent mobileSync = new MobileCacheSyncAgent(mobileMapServiceCache, mobileMapServiceConn);
                if (mobileSync.IsValid)
                {
                    mobileMapServiceConn.CreateCache(mobileMapServiceCache);
                    //mobileSync.StateChanged += new EventHandler(mobileSync_StateChanged);
                    //mobileSync.ProgressChanged += new EventHandler<MobileCacheSyncAgentProgressEventArgs>(mobileSync_ProgressChanged);
                    SyncResults mobileResults = mobileSync.Synchronize();
                    MessageBox.Show(mobileResults.DataSizeReceived.ToString());
                    mobileMapServiceCache.Open();
                    map1.DataSources.Add(mobileMapServiceCache);
                }
            }
            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!

Thanks!!
0 Kudos
2 Replies
KevinBupp
New Contributor III
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+   .(   ,%   '$   %                       
      ï�?f`
0 Kudos
KevinBupp
New Contributor III
I just tried this question over in the ArcGIS for Windows Phone SDK Forum and figured I would keep these two posts connected: http://forums.arcgis.com/threads/54582-Getting-quot-Invalid-file-or-corrupted-file-quot-Exception-wh...
0 Kudos