locked
The type or namespace name 'Synchronization' does not exist in the namespace 'Microsoft' RRS feed

  • Question

  • Hello,

    I am working on a WCF service built against .NET framework 4. I have installed Sync Framework 2.1 and later 4.0 CTP. I want to use SyncFX to synchronize tables between 2 SQL Express 2008 R2 servers. The environment is Windows Server 2008 R2.

    I have built a test application to provision / deprovision / sync my databases, which works fine. I used the similar code in my WCF service. The WCF service builds just fine. But when I want to update the service reference on the client or use Internet Explorer to browse to my service address, I get the above mentioned error message. Microsoft.Synchronization.dll, Microsoft.Synchronization.Data.dll and Microsoft.Synchronization.SqlServer.dll are referenced of course.

    Here is the source code of this very simple sync procedure:

     

    using MyService;
    using System;
    using System.Data.SqlClient;
    using Microsoft.Synchronization;
    using Microsoft.Synchronization.Data;
    using Microsoft.Synchronization.Data.SqlServer;
    
    namespace Common
    {
        public class Sync
        {
            public static void ExecuteSync()
            {
                SqlConnection clientConn = new SqlConnection("Data Source=localhost; Initial Catalog=Robno; Integrated Security=True");
                SqlConnection serverConn = new SqlConnection("Data Source=localhost; Initial Catalog=MainDB; Integrated Security=True");
                SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
                syncOrchestrator.LocalProvider = new SqlSyncProvider("SyncScope", clientConn);
                syncOrchestrator.RemoteProvider = new SqlSyncProvider("SyncScope", serverConn);
                syncOrchestrator.Direction = SyncDirectionOrder.Download;
                SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
            }
        }
    }
    

    and here is the output in IE:

     

    Server Error in '/MyService' Application.

     

    Compilation Error

     

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0234: The type or namespace name 'Synchronization' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

    Thursday, January 12, 2012 8:49 AM

Answers

  • Actually I have found the solution. Under "system.web -> compilation -> assemblies" node in my web.config, I needed to add the following lines:
            <add assembly="Microsoft.Synchronization, Version=2.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
            <add assembly="Microsoft.Synchronization.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
            <add assembly="Microsoft.Synchronization.Data.SqlServer, Version=3.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
    
    
    • Marked as answer by dejancg Thursday, January 12, 2012 9:20 AM
    Thursday, January 12, 2012 9:20 AM

All replies

  • Actually I have found the solution. Under "system.web -> compilation -> assemblies" node in my web.config, I needed to add the following lines:
            <add assembly="Microsoft.Synchronization, Version=2.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
            <add assembly="Microsoft.Synchronization.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
            <add assembly="Microsoft.Synchronization.Data.SqlServer, Version=3.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
    
    
    • Marked as answer by dejancg Thursday, January 12, 2012 9:20 AM
    Thursday, January 12, 2012 9:20 AM
  • Also to add to this point is that I had to install the Microsoft Sync SDK, and *not* the redistributable:

    http://www.microsoft.com/download/en/details.aspx?id=23217

    Tuesday, February 7, 2012 12:47 AM
  • add Synchronization assembly reference in VS.
    Sunday, August 10, 2014 2:55 PM
  • I had the same problem in x64 bit server environment. I had reference to sync assemblies and set Copy Local to "True" in Visual studio and deployed using Visual Studio Publish method. It copied all assemblies to bin folder as well. But didn't work.

    Also adding assemblies in the web.config section "system.web -> compilation -> assemblies" as shown in the answered reply didn't solve the problem.

    Finally I installed the Synchronization-v2.1-x64-ENU.msi on the server as well. And It worked.

    Monday, November 3, 2014 4:46 AM
  • you need to install it because Sync Fx still uses COM, so you cant simply copy assemblies your referenced.
    Tuesday, November 4, 2014 7:02 PM