-1

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.

chinna_82
  • 6,353
  • 17
  • 79
  • 134
  • What is the error message and at which line does it occur? And what have you tried? Put the error message in your favourite search engine and show what solutions you have found but do not work. – CodeCaster Oct 16 '12 at 08:16
  • Error : System.Reflection.TargetInvocationException was unhandled Message="TargetInvocationException" / InnerException: System.Net.WebException Message="Unable to connect to the remote server" – chinna_82 Oct 16 '12 at 08:46
  • I said: _"Put the error message in your favourite search engine and show what solutions you have found but do not work."_, not _"dump the error here"_. The error _"Unable to connect to the remote server"_ has 615.000 hits on Google, there's bound to be something useful there. Have you checked the firewall, for example? – CodeCaster Oct 16 '12 at 08:54

1 Answers1

0

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

chinna_82
  • 6,353
  • 17
  • 79
  • 134