-1

我正在尝试创建 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;

谢谢。

4

1 回答 1

0

我再次重新创建了 Web 服务,它现在可以工作了。问题是移动设备找不到我的本地网络服务。谢谢。

于 2012-10-16T09:30:30.363 回答