locked
Failed to create the provider. RRS feed

  • Question

  • I want to create a file syncronizer between two server. I mean I have two server and I want to make one of it as backup so I have to sync files between those.
    When I use Microsoft Sync Framework for files and create a FileSyncProvider, it returns this Exception :
    "Failed to create the provider."
    Is there any body who know where is the problem?
    TNX,
    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:16 PM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Tuesday, December 25, 2007 4:31 AM

All replies

  •  

    Can you post the code where you create/initialize the FileSyncProvider?

     

    Thanks!

    Wednesday, December 26, 2007 10:56 PM
  • Thanks for the response!

    Here is piece of code which return the Exception.

    TNX,

    Code Block

    private void Form2_Load(object sender, EventArgs e)
    {
        string _path = @"e:\sync";
        SyncId replicaId = GetReplicaId(Path.Combine(_path, "filesync.id"));
        FileSyncProvider provider = new FileSyncProvider(replicaId, _path);
        provider.DetectChanges();
        if (provider != null) provider.Dispose();
    }

    public static SyncId GetReplicaId(string idFilePath)
    {
        SyncId replicaId = null;
        if (File.Exists(idFilePath))
        {
            using (StreamReader sr = File.OpenText(idFilePath))
            {
                string strGuid = sr.ReadLine();
                if (!string.IsNullOrEmpty(strGuid)) replicaId =
                    new SyncId(new Guid(strGuid));
            }
        }
        if (replicaId == null)
        {
            using (FileStream idFile = File.Open(idFilePath,
                FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                using (StreamWriter sw = new StreamWriter(idFile))
                {
                    replicaId = new SyncId(Guid.NewGuid());
                    sw.WriteLine(replicaId.GetGuidId().ToString("D"));
                }
            }
        }
        return replicaId;
    }

    Thursday, December 27, 2007 5:06 AM
  • Just to make sure: Do you have access to the location you've created _path from your app? (Does

    this work if you pointed the _path to the location for the currently logged in user?

     

    -Moe

    Friday, February 15, 2008 7:35 AM