Question

I'm trying to create WCF to sync my mobile device with my server. When i try to click sync button it throws TargetInvocationException. Below is the Sync() method.

Code

            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;

Thanks.

Was it helpful?

Solution

I've recreated the Web Service again and it works now. The problem was the mobile device couldnt find my local webservice. Thanks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top