-1
我正嘗試創建WCF以將我的移動設備與我的服務器同步。當我嘗試點擊同步按鈕時,它會引發TargetInvocationException。以下是Sync()方法。WCF - TargetInvocationException未處理
代碼
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;
感謝。
什麼是錯誤信息和它在哪一行發生?你有什麼嘗試?將錯誤消息放入您最喜愛的搜索引擎中,並顯示您找到的但未起作用的解決方案。 – CodeCaster
Error:System.Reflection.TargetInvocationException was unhandled Message =「TargetInvocationException」/ InnerException:System.Net.WebException Message =「無法連接到遠程服務器」 –
我說:_「將錯誤消息放入您最喜歡的搜索引擎,並顯示你找到了什麼解決方案,但不工作。「_,而不是_」在這裏轉儲錯誤「_。錯誤_「無法連接到遠程服務器」_在Google上有615.000次點擊,這裏肯定有用處。例如,你檢查過防火牆嗎? – CodeCaster