用于移动设备的ADO.NET解决方案的同步服务 - ArgumentNullException

时间:2012-07-10 07:16:16

标签: wcf windows-ce

我正在尝试在移动设备和数据库服务器之间创建同步。我正在关注this tutorial并在sych()函数中得到ArgumentNullException Value can not be null. Parameter name: ServerSyncProvider

代码

 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;

        }

1 个答案:

答案 0 :(得分:0)

由于错误显示“值不能为null。参数名称:ServerSyncProvider”

表示未初始化

你错过了一行代码

NorthwindCacheSyncAgent syncAgent = new NorthwindCacheSyncAgent();

syncAgent.RemoteProvider = syncProxy
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();