GeodatabaseSyncTask.CreateAsync Error

1282
3
03-15-2017 12:16 PM
ChadYoder1
Occasional Contributor II

Using an invalid Url (misspelling or not sync enabled) will terminate the app (iOS, Android, UWP) without notice to the user.

1. Seems like there should be some protection so this doesn't terminate the app.  It doesn't matter if CreateAsync is wrapped in a try/catch.

2. Is there a way to check the service prior to calling CreateAsync to check it is valid and sync enabled, other than downloading and inspecting the service definition?

Thanks.

0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor

I can't seem to reproduce this though. I am using XAML Forms with the following code and in all instances, I'm able to catch the exception without the app getting terminated. iOS, Android, UWP seem to work. Is there a different Url, I should try? Thanks.

private async void Button_Clicked(object sender, EventArgs e)
{
    try
    {
        // does not support sync
        //var task = await GeodatabaseSyncTask.CreateAsync(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Notes/FeatureServer"));
        // folder not found
        //var task = await GeodatabaseSyncTask.CreateAsync(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/doesnotexist"));
     // error occured while sending request
        var task = await GeodatabaseSyncTask.CreateAsync(new Uri("http://doesnotexist.arcgisonline.com/arcgis/rest/services/Notes/FeatureServer"));
    }
    catch (Exception ex)
    {
        await DisplayAlert("Error", ex.Message, "OK");
    }
}
0 Kudos
ChadYoder1
Occasional Contributor II

Thanks for your reply.  I have a method that looks like this, and it will terminate the app every time:

public static async Task<Geodatabase> GenerateOfflineGdbAsync(string mapName, Envelope mapExtent)
{
    //Create the task and get the default parameters
    GeodatabaseSyncTask gdbSyncTask = null;
    var url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Notes/FeatureServer";
    //TODO: This will crash the app if not a valid sync service....how to avoid??
    try {
        gdbSyncTask = await GeodatabaseSyncTask.CreateAsync (new Uri (url));
    } catch (Exception ex) {
        throw new Exception ("An error occurred while creating the sync task.  Check the sync Url is correct and try again.\n\n" + ex.Message);
    }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

There may be some other things at play here, for example, there is code in place before this to make sure the device doesn't enter sleep mode.  I wouldn't think this would have an impact on this, but just wanted to throw it out there.

I have the HockeyApp crash logs, but it doesn't seem to share much useful information.  I can share that if you think it is worth it.  I'll try tomorrow to grab more debug info from the device to see if I can more helpful information.

I'll also try to pull out the code into a self contained example to see if the issue still happens and let you know.

Thanks!

0 Kudos
ChadYoder1
Occasional Contributor II

Well, I'm not able to reproduce with your code when added to a button, however, it still happens in the code using the workflow of our app.

So, appears not to be an issue with the API, but rather something in our app.

Thanks for your help.

0 Kudos