我正在尝试创建 WCF 以将我的移动设备与我的服务器同步。当我尝试单击同步按钮时,它会抛出 TargetInvocationException。下面是 Sync() 方法。
代码
Cursor.Current = Cursors.WaitCursor;
CustomerProxy.CustomerCacheSyncService svcProxy = new CustomerProxy.CustomerCacheSyncService();
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.
CustomerCacheSyncAgent syncAgent = new CustomerCacheSyncAgent();
syncAgent.RemoteProvider = syncProxy;
/*throws error below code*/
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
// TODO: Reload your project data source from the local database (for example, call the TableAdapter.Fill method).
customer_ConfirmationTableAdapter.Fill(testHHDataSet.Customer_Confirmation);
// Show synchronization statistics
MessageBox.Show("Changes downloaded: " + syncStats.TotalChangesDownloaded.ToString()
+ "\r\nChanges Uploaded: " + syncStats.TotalChangesUploaded.ToString());
Cursor.Current = Cursors.Default;
谢谢。