Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

MobileServiceClient.SyncContext.PushAsync() suddenly stopped working

$
0
0

The fourth line below suddenly stopped working. The exception error is "Push operation has failed. See the PushResult for details." When I look inside the exception, all I am getting is the standard "Object reference not instance to an instance of an object" as part of the inner exception.

public async void SyncPushOnly()
{
ReadOnlyCollection syncErrors = null;
try
{
await this.client.SyncContext.PushAsync(); <-- This line suddenly stopped working
}
catch (MobileServicePushFailedException exc)
{
if (exc.PushResult != null)
{
syncErrors = exc.PushResult.Errors;
}

            System.Diagnostics.Debug.WriteLine("Exception in SyncPushOnly EXC: " + exc.Message, "ERROR");
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("Exception in SyncPushOnly EX: " + ex.Message, "ERROR");
        }
        // Simple error/conflict handling. A real application would handle the various errors like network conditions,
        // server conflicts and others via the IMobileServiceSyncHandler.
        if (syncErrors != null)
        {
            foreach (var error in syncErrors)
            {
                if (error.OperationKind == MobileServiceTableOperationKind.Update && error.Result != null)
                {
                    //Update failed, reverting to server's copy.
                    await error.CancelAndUpdateItemAsync(error.Result);
                }
                else
                {
                    // Discard local change.
                    await error.CancelAndDiscardItemAsync();
                }

                Debug.WriteLine(@"Error executing SyncAuthSync operation. Item: {0} ({1}). Operation discarded.", error.TableName, error.Item["id"]);
            }
        }

    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>