缺少程序集引用SqlCeSyncProvider C#

时间:2014-04-28 06:25:47

标签: c# .net reference .net-assembly using

我尝试在同步代码中使用SqlCeSyncProvider,但它会出现错误SqlCeSyncProvider dos not exist, Are you missing assembly referenceMSDN SqlCeSyncProvider Microsoft.Synchronization.Data.SqlServerCe using Microsoft.Synchronization.Data.SqlServerCe; using Microsoft.Synchronization.Data.SqlServerCe.SqlCeSyncProvider; The type or namespace name 'SqlCeSyncProvider' does not exist in the namespace 'Microsoft.Synchronization.Data.SqlServerCe' (are you missing an assembly reference?) {} {{}}

我尝试了2.0.0.0,3.1.0.0和3.5.0.0版本的程序集,但不了解可能出现的问题。我也尝试使用 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using Microsoft.Synchronization; using Microsoft.Synchronization.Data; using Microsoft.Synchronization.Data.SqlServer; using Microsoft.Synchronization.Data.SqlServerCe; namespace ExecuteExpressSync { class Program { static void Main(string[] args) { SqlConnection clientConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=SyncExpressDB; Trusted_Connection=Yes"); SqlConnection serverConn = new SqlConnection("Data Source=localhost; Initial Catalog=SyncDB; Integrated Security=True"); // create the sync orhcestrator SyncOrchestrator syncOrchestrator = new SyncOrchestrator(); // set local provider of orchestrator to a sync provider associated with the // ProductsScope in the SyncExpressDB express client database syncOrchestrator.LocalProvider = new SqlSyncProvider("ProductsScope", clientConn); // set the remote provider of orchestrator to a server sync provider associated with // the ProductsScope in the SyncDB server database syncOrchestrator.RemoteProvider = new SqlSyncProvider("ProductsScope", serverConn); // set the direction of sync session to Upload and Download syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload; // subscribe for errors that occur when applying changes to the client ((SqlCeSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed); // Error on this line // execute the synchronization process SyncOperationStatistics syncStats = syncOrchestrator.Synchronize(); // print statistics Console.WriteLine("Start Time: " + syncStats.SyncStartTime); Console.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal); Console.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal); Console.WriteLine("Complete Time: " + syncStats.SyncEndTime); Console.WriteLine(String.Empty); } static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e) { // display conflict type Console.WriteLine(e.Conflict.Type); // display error message Console.WriteLine(e.Error); } } } ,但它给出了错误

{{1}}

这是否意味着Microsoft doc是错误的?

完整的代码示例

{{1}}

0 个答案:

没有答案