System.UnauthorizedAccessException because it can't access : "HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server Compact Edition\v3.5

Unanswered System.UnauthorizedAccessException because it can't access : "HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server Compact Edition\v3.5

  • sexta-feira, 6 de abril de 2012 17:44
     
      Contém Código

    HI,

    My development machine synthronization working fine, but when i install application to server its raise following error

    System.UnauthorizedAccessException because it can't access :

    "HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server Compact Edition\v3.5

    According to my research i saw this explanation

    "set the ClientId property on the client provider (SqlCeClientSyncProvider) in your client application"

    How can set clientid? Is there any code?

    here is my code

       LocalDataCache1SyncAgent syncAgent = new LocalDataCache1SyncAgent();
                Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();

Todas as Respostas

  • sábado, 7 de abril de 2012 01:50
    Moderador
     
      Contém Código
     var localProvider = (ClientSyncProvider) syncAgent.LocalProvider;
     localProvider.ClientId = "<your value here, must be a guid>";

  • domingo, 8 de abril de 2012 03:11
     
      Contém Código

    I have done this way, is it correct

     // Call SyncAgent.Synchronize() to initiate the synchronization process.
                // Synchronization only updates the local database, not your project's data source.
                LocalDataCache1SyncAgent syncAgent = new LocalDataCache1SyncAgent();
                Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
                var localProvider = (ClientSyncProvider)syncAgent.LocalProvider;
                localProvider.ClientId = Guid.Parse("53406795-968f-4205-904d-12f7388316eb");

  • domingo, 8 de abril de 2012 10:09
    Moderador
     
     
    you should set the clientid before you call synchronize.