ArcGIS for Windows Mobile Create Cache with Token not working

2069
0
03-30-2016 08:17 AM
by Anonymous User
Not applicable

I am using ArcGIS for Windows mobile.  I can successfully create a mobile cache if the service is not secured.  However if I add security or try to use a token it fails on the CreateCache with a nullReferenceException.  Any ideas are appreciated!

             //@"http://<YourServer>/<YourArcGISServerInstance>/rest/services/<YourMobileServiceName>/MapServer/MobileServer";

                MobileServiceConnection mobileServiceConnection = new MobileServiceConnection();

                mobileServiceConnection.Url = mobileServiceUrl;

              

//if the line below is commented out this works flawlessly.  If I add this line on the CreateCache line below it will fail

                mobileServiceConnection.TokenCredential = new ESRI.ArcGIS.Mobile.CatalogServices.TokenCredential("MyUserName", "MyPassWord");

//these next 2 lines are just an alternate that I tried               

//mobileServiceConnection.TokenCredential.UserName = "MyUserName";

  //              mobileServiceConnection.TokenCredential.Password = "MyPassWord";

                mobileCache1 = new MobileCache(cacheStoragePath);

                if (mobileCache1.CacheExists == true)

                    mobileCache1.DeleteCache();

                if (mobileServiceConnection.IsValid)

                {

                    MobileCacheTextBox.Text = "isValid";

                }

                else

                {

                    MobileCacheTextBox.Text = "Not Valid";

                }

          //the line below is where it returns a nullReferenceException when the Token is being set

                mobileServiceConnection.CreateCache(mobileCache1);

                mobileCache1.Open();

                           

                return true;

0 Kudos
0 Replies