locked
SqlCeSyncProvider not defined ???? RRS feed

  • Question

  • Hello,

    I am try to do this tutorial:

    http://msdn.microsoft.com/en-us/library/ff928494(v=SQL.110).aspx

    I get to the last part with this code:

    Imports

     

     

    System

    Imports

     

     

    System.Data

    Imports

     

     

    System.Data.SqlClient

    Imports

     

     

    System.Data.SqlServerCe

    Imports

     

     

    Microsoft.Synchronization

    Imports

     

     

    Microsoft.Synchronization.Data

    Imports

     

     

    Microsoft.Synchronization.Data.SqlServer

    Imports

     

     

    Microsoft.Synchronization.Data.SqlServerCe

    Module

     

     

    Module1

     

     

    Sub Main()

     

     

    ' create a connection to the SyncCompactDB database

     

     

    Dim clientConn As New SqlCeConnection("Data Source='C:\Users\MutlyP\Documents\Visual Studio 2010\Projects\SyncSQLServerAndSQLCompact\SyncCompactDB.sdf'")

     

     

    ' create a connection to the SyncDB server database

     

     

    Dim serverConn As New SqlConnection("Data Source=localhost; Initial Catalog=SyncDB; Integrated Security=True")

     

     

    ' create the sync orhcestrator

     

     

    Dim syncOrchestrator As New SyncOrchestrator()

     

     

    ' set local provider of orchestrator to a CE sync provider associated with the

     

     

    ' ProductsScope in the SyncCompactDB compact client database

    syncOrchestrator.LocalProvider =

     

    New SqlCeSyncProvider("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

     

     

    'DirectCast(syncOrchestrator.LocalProvider, SqlCeSyncProvider).ApplyChangeFailed += New EventHandler(Of DbApplyChangeFailedEventArgs)(Program_ApplyChangeFailed)

     

     

    ' execute the synchronization process

     

     

    Dim syncStats As SyncOperationStatistics = 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)

     

     

    End Sub

     

     

    Private Sub Program_ApplyChangeFailed(ByVal sender As Object, ByVal e As DbApplyChangeFailedEventArgs)

     

     

    ' display conflict type

     

     

    Console.WriteLine(e.Conflict.Type)

     

     

    ' display error message

     

     

    Console.WriteLine(e.[Error])

     

     

    End Sub

    End

     

     

    Module

    This line of code:

    New

     

     

    SqlCeSyncProvider("ProductsScope", clientConn)

    gives me the error:

    "Type SqlCeSyncProvider is not defined"

    But as you can see I have the reference:

    Microsoft.Synchronization.Data.SqlServerCe

    and it is 3.5 version.

    Why am I getting this error.

    Please help.

    Thank You

     

    Thursday, January 27, 2011 2:59 AM

Answers

  • Make sure that you have added the following references to your project through Visual Studio.  Imports adds a namespace to your project but it does not automatically adds the reference DLL to your project.  You need to make sure that you have added the following references to your project:

    • Microsoft.Synchronization
    • Microsoft Synchronization.Data
    • Microsoft.Synchronization.Data.SqlServer
    • Microsoft.Synchronization.Data.SqlServerCe
    • System.Data.SqlServerCe

    You can add these by right-clicking on your project and selecting Add Reference.

    In addition, if your OS Architecture is 64-bit, and you have installed the Microsoft Synchronization 2.1 SDK for x64, you will have to change the target platform in your project because VB defaults to x86.  To do this, right click on your project, click on Preferences, go to the Compile Tab, then click on Advance Compile Options and change the Target CPU to x64.  This link shows you how to do this http://msdn.microsoft.com/en-us/library/8ck8e1y2.aspx.

     


    Maria del Mar Alvarez Rohena Microsoft Sync Framework
    Wednesday, February 2, 2011 12:02 AM

All replies

  • did you installed the syncFx V2.1 SDK on the dev box ? http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ee6af141-79d0-4351-a4a0-ea89bb29dcf5&displaylang=en

     

    thanks

    Yunwen


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, January 27, 2011 8:17 PM
  • Yes I did.

    Thanks

    Matt

    Thursday, January 27, 2011 10:42 PM
  • Make sure that you have added the following references to your project through Visual Studio.  Imports adds a namespace to your project but it does not automatically adds the reference DLL to your project.  You need to make sure that you have added the following references to your project:

    • Microsoft.Synchronization
    • Microsoft Synchronization.Data
    • Microsoft.Synchronization.Data.SqlServer
    • Microsoft.Synchronization.Data.SqlServerCe
    • System.Data.SqlServerCe

    You can add these by right-clicking on your project and selecting Add Reference.

    In addition, if your OS Architecture is 64-bit, and you have installed the Microsoft Synchronization 2.1 SDK for x64, you will have to change the target platform in your project because VB defaults to x86.  To do this, right click on your project, click on Preferences, go to the Compile Tab, then click on Advance Compile Options and change the Target CPU to x64.  This link shows you how to do this http://msdn.microsoft.com/en-us/library/8ck8e1y2.aspx.

     


    Maria del Mar Alvarez Rohena Microsoft Sync Framework
    Wednesday, February 2, 2011 12:02 AM