我正在尝试创建WCF以将我的移动设备与服务器同步。当我尝试单击同步按钮时,它会抛出目标调用异常。下面是 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()
+ "rnChanges Uploaded: " + syncStats.TotalChangesUploaded.ToString());
Cursor.Current = Cursors.Default;
谢谢。
我再次重新创建了 Web 服务,它现在可以工作了。问题是移动设备找不到我的本地网络服务。谢谢。