Select to view content in your preferred language

CreateCache throw exception : Value does not fall within the expected range.

2891
2
07-29-2011 10:33 PM
JamilHallal
Deactivated User
The below code throw an exception on "CreateCache", note that the MobiService is running well
mobileCache1.DeleteCache();
mobileServiceConnection1.Url = @"http://myserver/ArcGIS/services/MobiService/MapServer/MobileServer";
mobileServiceConnection1.WebClientProtocolType = WebClientProtocolType.BinaryWebService;
MobileCacheSyncAgent mobilesync = new MobileCacheSyncAgent(mobileCache1, mobileServiceConnection1);
mobileServiceConnection1.CreateCache(mobileCache1);
mobilesync.Synchronize();

Exception: "Value does not fall within the expected range."

did anyone face such issue?
0 Kudos
2 Replies
AkhilParujanwala
Regular Contributor
When you are sync your data with the server, if there are any data with incorrect values in the fields you will get that error.

For example a range domain for a field only accepts values from 0 to 10. But in your code you put -1. Then you try to sync, you will get that value error.

Try to sync just with one data collected, and determine which value if wrong/invalid. You can also look at your featureclass in ArcCatalog and determine what are your allowable values for each field.

This may also be an issue with nulls, if so, update to build 2500, this has solved a few issues for me.
0 Kudos
Hang_KwaiPun
Emerging Contributor
Hi jhallal ,

There might be another trival reason: you haven't opened your newly created cache yet! You might want to do the following:

if(!con.CreateCache(cache))
  //complain that cache isn't created
cache.Open();  //or OpenCache()? i can't recall right now...
if(!cache.IsOpen())
  //more complaints
//use your MobileCacheSyncAgent to sync your data.

And as AkhilP mentioned, there might be somthing wrong with individual layers. So you might want to use FeatureSyncAgent to synchronize data for individual layers. That not only can help you trace the problem easier, but also might save your time (since it will only sync what the layer you need).
0 Kudos