I’m trying to create a sync between my mobile and database server. I am following this tutorial and it get ArgumentNullException Value can not be null. in sych() function.
Parameter name: ServerSyncProvider
Code
private void Sync()
{
Cursor.Current = Cursors.WaitCursor;
WebReference.NorthwindCacheSyncService svcProxy = new WebReference.NorthwindCacheSyncService();
Microsoft.Synchronization.Data.ServerSyncProviderProxy syncProxy =
new Microsoft.Synchronization.Data.ServerSyncProviderProxy(svcProxy);
// Call SyncAgent.Synchronize() to initiate the synchronization process.
// Synchronization only updates the local database, not your project's data source.
NorthwindCacheSyncAgent syncAgent = new NorthwindCacheSyncAgent();
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
// TODO: Reload your project data source from the local database (for example, call the TableAdapter.Fill method).
// Show synchronization statistics
MessageBox.Show("Changes downloaded: " + syncStats.TotalChangesDownloaded.ToString()
+ "\r\nChanges Uploaded: " + syncStats.TotalChangesUploaded.ToString());
Cursor.Current = Cursors.Default;
}
As the error says “Value can not be null. Parameter name: ServerSyncProvider”
Means it is not initialized
You have missed one line of code inbetween
NorthwindCacheSyncAgent syncAgent = new NorthwindCacheSyncAgent();