Trying to sync a local mobile geodatabase to a feature server using ESRI C# SDK and WPF. The schemas match, there are no permission problems, the network is operational. Here's the code. Nothing revealed in the inner exceptions except vague messages that offer no insights. What's wrong with this code?
var LocalGeodatabasePath = "...";
var FeatureServiceUrl = "...";
try
{
// Load the local geodatabase
Geodatabase localGeodatabase = await Geodatabase.OpenAsync(LocalGeodatabasePath);
Console.WriteLine("Local geodatabase loaded.");
// Create the SyncGeodatabaseTask
var syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(FeatureServiceUrl));
Console.WriteLine("SyncGeodatabaseTask created.");
// Create the SyncGeodatabaseParameters
SyncGeodatabaseParameters syncParams = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(localGeodatabase);
// Check layers in the sync parameters
foreach (var layerOption in syncParams.LayerOptions)
{
Console.WriteLine($"LayerOption for layer {layerOption.LayerId}");
}
Console.WriteLine("SyncGeodatabaseParameters created.");
// Sync direction: Push local changes to the server
syncParams.GeodatabaseSyncDirection = SyncDirection.Bidirectional;
// Optionally, you can adjust other sync parameters here
// Create a job to synchronize the geodatabase
SyncGeodatabaseJob syncJob = syncTask.SyncGeodatabase(syncParams, localGeodatabase);
// Handle job status changes
syncJob.JobChanged += (s, e) =>
{
Console.WriteLine($"Job status changed: {syncJob.Status}");
if (syncJob.Status == JobStatus.Succeeded)
{
Console.WriteLine("Synchronization succeeded.");
}
else if (syncJob.Status == JobStatus.Failed)
{
Console.WriteLine($"Synchronization failed: {syncJob.Error.Message}");
}
};
// Start the job
syncJob.Start();
// Wait for the job to complete
var syncResult = await syncJob.GetResultAsync();
// Check for errors
if (syncJob.Status == JobStatus.Succeeded)
{
// Retrieve and store the replica ID
var replicaInfo = syncResult;
Console.WriteLine($"Synchronization complete. Replica ID: {replicaInfo.ToString()}");
}
else
{
Console.WriteLine($"Synchronization failed: {syncJob.Error.Message}");
}
}
catch (ArcGISWebException ex)
{
Console.WriteLine($"ArcGISWebException: {ex.Message}");
if (ex.InnerException != null)
{
Console.WriteLine($"Inner Exception: {ex.InnerException.Message}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex.Message}");
if (ex.InnerException != null)
{
Console.WriteLine($"Inner Exception: {ex.InnerException.Message}");
}
}
Job status changed: Started
Job status changed: Started
Job status changed: Started
Job status changed: Started
Job status changed: Started
Job status changed: Failed
Synchronization failed: Unable to complete operation.
Exception thrown: 'Esri.ArcGISRuntime.Http.ArcGISWebException' in mscorlib.dll
ArcGISWebException: Unable to complete operation.
Using:
ESRI.ArcGIS.Client
run-time version: 4.0.30319
version: 3.0.0.146
Feature service hosted on AGOL 10.91
Remote and local schemas match.