【发布时间】:2012-10-16 08:13:00
【问题描述】:
我正在尝试创建 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;
谢谢。
【问题讨论】:
-
错误信息是什么,它出现在哪一行?你试过什么?将错误消息放在您最喜欢的搜索引擎中,并显示您找到了哪些解决方案但不起作用。
-
错误:System.Reflection.TargetInvocationException 未处理 Message="TargetInvocationException" / InnerException: System.Net.WebException Message="无法连接到远程服务器"
-
我说:“把错误信息放到你最喜欢的搜索引擎中,显示你找到了哪些解决方案但不起作用。”,而不是“转储错误这里”。 "Unable to connect to the remote server" 错误在 Google 上有 615.000 次点击,那里肯定有一些有用的东西。例如,您检查过防火墙吗?
标签: wcf synchronization smartclient