0

我正在尝试在我的移动和数据库服务器之间创建同步。我正在关注本教程,它进入ArgumentNullException Value can not be null. Parameter name: ServerSyncProvider了 sych() 函数。

代码

 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;

        }
4

1 回答 1

0

正如错误所说“值不能为空。参数名称:ServerSyncProvider”

表示未初始化

你错过了中间的一行代码

NorthwindCacheSyncAgent syncAgent = new NorthwindCacheSyncAgent();

syncAgent.RemoteProvider = syncProxy
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
于 2012-07-11T12:18:17.423 回答