Getting Error "Unable to obtain a new server anchor" in OfflineAppDemo-Builder Project. RRS feed

  • Question

  • Hi all
    I am using code from

    some how i am getting error when i call syncAgent.Synchronize() method. Error is describe below. I have created pub database that is given in the example.

    "Unable to obtain a new server anchor. Make sure that you can establish a connection to the server database and that the SelectNewAnchorCommand property of the DbServerSyncProvider is specified correctly."

    I am putting my code here...if anyone find problem then please reply me.

    System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
           connString = "Data Source=" +  "System.IO.Path.GetDirectoryName(asm.Location) + "\\VMukti.sdf";

                    if (!File.Exists(strFilePath))

                        SqlCeEngine clientEngine = new SqlCeEngine(connString);

    DbServerSyncProvider  serverSyncProvider = new DbServerSyncProvider();

                    SyncAgent syncAgent = new SyncAgent();
                    syncAgent.ServerSyncProvider = serverSyncProvider;

                    clientSyncProvider = new SqlCeClientSyncProvider(strClientConnectionString);
                    syncAgent.ClientSyncProvider = clientSyncProvider;
                    SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

                    builder["Data Source"] = "\\SQLExpress";
                    builder["integrated Security"] = true;
                    builder["Initial Catalog"] = "pub";
                    SqlConnection serverConnection = new SqlConnection(builder.ConnectionString);
                    serverSyncProvider.Connection = serverConnection;               
                    SyncTable tableOrders = new SyncTable("orders");
                    tableOrders.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
                    tableOrders.SyncDirection = SyncDirection.Bidirectional;

                    SyncTable tableOrderDetails = new SyncTable("order_details");
                    tableOrderDetails.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
                    tableOrderDetails.SyncDirection = SyncDirection.Bidirectional;

                    SyncGroup orderGroup = new SyncGroup("AllChanges");
                    tableOrders.SyncGroup = orderGroup;
                    tableOrderDetails.SyncGroup = orderGroup;


                    SqlSyncAdapterBuilder ordersBuilder = new SqlSyncAdapterBuilder();
                    ordersBuilder.Connection = serverConnection;
                    ordersBuilder.SyncDirection = SyncDirection.Bidirectional;

                    // base table
                    ordersBuilder.TableName = "orders";

                    // tombstone table
                    ordersBuilder.TombstoneTableName = "orders_tombstone";

                    // tracking\sync columns
                    ordersBuilder.CreationTrackingColumn = @"create_timestamp";
                    ordersBuilder.UpdateTrackingColumn = @"update_timestamp";
                    ordersBuilder.DeletionTrackingColumn = @"update_timestamp";
                    ordersBuilder.UpdateOriginatorIdColumn = @"update_originator_id";

                    SyncAdapter ordersSyncAdapter = ordersBuilder.ToSyncAdapter();
                    ((SqlParameter)ordersSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_last_received_anchor"]).DbType = DbType.Binary;
                    ((SqlParameter)ordersSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_new_received_anchor"]).DbType = DbType.Binary;

                    SqlSyncAdapterBuilder orderDetailsBuilder = new SqlSyncAdapterBuilder();
                    orderDetailsBuilder.SyncDirection = SyncDirection.Bidirectional;
                    orderDetailsBuilder.Connection = serverConnection;

                    // base table
                    orderDetailsBuilder.TableName = "order_details";

                    // tombstone table
                    orderDetailsBuilder.TombstoneTableName = "order_details_tombstone";

                    // tracking\sync columns
                    orderDetailsBuilder.CreationTrackingColumn = @"create_timestamp";
                    orderDetailsBuilder.UpdateTrackingColumn = @"update_timestamp";
                    orderDetailsBuilder.DeletionTrackingColumn = @"update_timestamp";
                    orderDetailsBuilder.UpdateOriginatorIdColumn = @"update_originator_id";

                    SyncAdapter orderDetailsSyncAdapter = orderDetailsBuilder.ToSyncAdapter();
                    ((SqlParameter)orderDetailsSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_last_received_anchor"]).DbType = DbType.Binary;
                    ((SqlParameter)orderDetailsSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_new_received_anchor"]).DbType = DbType.Binary;

                    SqlCommand anchorCmd = new SqlCommand();
                    anchorCmd.CommandType = CommandType.Text;
                    anchorCmd.CommandText = "Select @" + SyncSession.SyncNewReceivedAnchor + " = @@DBTS";
                    anchorCmd.Parameters.Add("@" + SyncSession.SyncNewReceivedAnchor, SqlDbType.Timestamp).Direction = ParameterDirection.Output;

                    serverSyncProvider.SelectNewAnchorCommand = anchorCmd;

                     SqlCommand clientIdCmd = new SqlCommand();
                    clientIdCmd.CommandType = CommandType.Text;
                    clientIdCmd.CommandText = "SELECT @" + SyncSession.SyncOriginatorId + " = 1";
                    clientIdCmd.Parameters.Add("@" + SyncSession.SyncOriginatorId, SqlDbType.Int).Direction = ParameterDirection.Output;

                    serverSyncProvider.SelectClientIdCommand = clientIdCmd;


    Thanks & Regards,
    Meet Vjiay Shah
    • Moved by Max Wang_1983 Friday, April 22, 2011 6:48 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, September 13, 2007 2:19 PM


  • Hi,


    Are you sure you are running beta 2 of the runtime? You could uninstall exiting package and reinstall beta 2 version.

    Another way to debug this is to use SQL profiler. If the new anchor command was executed correctly, yet you still getting the same error then you must have the old bits since this is an area that was revised from the beta 1 bits.


    Hope that helps.



    Thursday, September 13, 2007 6:26 PM

All replies

  • Hi,


    Are you sure you are running beta 2 of the runtime? You could uninstall exiting package and reinstall beta 2 version.

    Another way to debug this is to use SQL profiler. If the new anchor command was executed correctly, yet you still getting the same error then you must have the old bits since this is an area that was revised from the beta 1 bits.


    Hope that helps.



    Thursday, September 13, 2007 6:26 PM

  • Thanks for reply.
    Actually i was not using runtime environment instead of that i have put some dlls to my debug folder,those are required for synchronization.


    But when i install runtime beta 2 and reference to those dlls now it works fine.
    Is there any thing new in beta 2.

    Thanks & Regards.
    Meet Vijay Shah
    Friday, September 14, 2007 8:55 AM

  • Hi.

    I am having one question for you. When i install beta 2 and run application at that time it is working fine but. when i uninstall the beta 2 and simply copy the required dlls to debug folder at that time it is giving me this error

    "Unable to load DLL 'sqlceme35.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

    I have put below dlls to my debug folder.


    Thanks & Regards,
    Meet Vijay Shah
    Friday, September 14, 2007 11:29 AM
  • Hi,


    SQL CE dlls are native and needs to be registered. Try running regsvr32 against sqlceme35.dll and possibly the rest. I think this should solve the issue.



    Friday, September 14, 2007 3:39 PM
  • "Unable to load DLL 'sqlceme35.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

    I found a solution to this and some other "known issues" with VS 2005 Express.  This solution works on Visual Studio 2008 Express:

    The VB and C# Express products to not expose the Target property inside the development environment. You will need to carefully modify the project file using a text or XML editor.
    1.    Close the project and/or solution
    2.    Select Open File from the File menu
    3.    Navigate to the project directory, and highlight the project file
    4.    Press the Open button, the project file should open in the XML editor
    5.    Locate the first <PropertyGroup> section and add the following line:
    1.    Save the project file
    2.    Reopen the project and/or solution using Open Project/Solution from the File menu
    3.    Continue with development, debugging, and testing

    To clarify which project file to open, it is the one ending in .csproj

    Original Source of the Fix
    Wednesday, December 12, 2007 9:00 PM
  • Hi all:


    I'm getting the same error with the exception that I am using the VB example taken from the "Getting Started: A synchronization Services Application", Syncronization Services for ADO.NET Documentation.


    The line I receive the error is:


    Dim syncStatistics As SyncStatistics = sampleSyncAgent.Synchronize()


    I just installed VS2008 Standard.  I have verified I have a connection to my 2005 Server and from what I can see, SQLCe is creating the database.


    Can someone give me a getter idea as to what to look for.  I didn't see anything in my files as described previously.


    If you need additional code, look in the documentation or let me know and I will past in this forum.


    Your help is apprecated!


    Saturday, April 5, 2008 3:27 AM
  • I am using the same "usp_GetNewBatchAnchor" stored procedure technique and I am getting the "Unable to obtain a new server anchor" exception.  I have verified that the server is getting the call using Sql Profiler.


    Has this issue been resolved?  Please provide an answer if it has and please include more details.




    ~ Darrin ~

    Monday, May 5, 2008 5:14 PM
  • I am getting the same error. I'm pretty sure I have both versions installed. The versions of the dlls as referenced in the project are:


    Microsoft.Synchronisation |

    Microsoft.Synchronisation.Data |

    Microsoft.Synchronisation.Data.Server |

    Microsoft.Synchronisation.Data.Server |


    How can I tell which beta version I am running?


    Tuesday, July 29, 2008 1:25 AM