We're working on a utility to automate (and move out of modelbuilder) our process for synchronizing our production SDEGDB with our publication SDEGDB, but I'm getting stuck when I actually run the synchronization utilizing the SynchronizeReplica() method (GeodatabaseDistributed.IReplicationAgent). I'm looping through both our pub and prod databases and catching the matching replicas but the method is attempting to look for the replica from a separately owned gdb AND it's adding the ID number for the parent replica to the name when it tries to run -- in this case it's trying to hit one of the child versions to get the replica and adding parentReplica.ID to the end of the replica name.the relevant section from the stack trace:System.Exception was unhandled Message="Create replica errored: Version not found [GCWWGIS.WaterReplicaToEngweb_21], Error Code: -2147215997" Source="AutomatedReconcileCsharp" StackTrace: at AutomatedReconcileCsharp.formBatchReconcile.SynchronizeReplica(IGeoDataServer parentGDS, IGeoDataServer childGDS, String replicaName, esriReplicationAgentReconcilePolicy conflictPolicy, esriReplicaSynchronizeDirection syncDirection, Boolean columnLevel) in C:\Documents and Settings\lbadgerow\My Documents\Visual Studio 2008\Projects\AutomatedReconcileCsharp\AutomatedReconcileCsharp\formBatchReconcile.cs:line 458 at AutomatedReconcileCsharp.formBatchReconcile.SyncWithPub(IWorkspace sde) in C:\Documents and Settings\lbadgerow\My Documents\Visual Studio 2008\Projects\AutomatedReconcileCsharp\AutomatedReconcileCsharp\formBatchReconcile.cs:line 372 IGPReplicas gpReplicas = parentGDS.Replicas;
IGPReplica parentReplica = null;
for (int i = 0; i < gpReplicas.Count; i++)
{
// See if the unqualified replica name matches the replicaName parameter.
IGPReplica currentReplica = gpReplicas.get_Element(i);
String currentReplicaName = currentReplica.Name;
int dotIndex = currentReplicaName.LastIndexOf(".") + 1;
String baseName = currentReplicaName.Substring(dotIndex,
currentReplicaName.Length - dotIndex);
if (baseName.ToLower().Equals(replicaName.ToLower()))
{
parentReplica = currentReplica;
break;
}
}
// Check to see if the parent replica was found.
if (parentReplica == null)
{
throw new ArgumentException(
"The requested replica could not be found on the parent GDS.");
}
// Iterate through the replica of the child GeoDataServer.
gpReplicas = childGDS.Replicas;
IGPReplica childReplica = null;
for (int i = 0; i < gpReplicas.Count; i++)
{
// See if the unqualified replica name matches the replicaName parameter.
IGPReplica currentReplica = gpReplicas.get_Element(i);
String currentReplicaName = currentReplica.Name;
int dotIndex = currentReplicaName.LastIndexOf(".") + 1;
String baseName = currentReplicaName.Substring(dotIndex,
currentReplicaName.Length - dotIndex);
if (baseName.ToLower().Equals(replicaName.ToLower()))
{
childReplica = currentReplica;
break;
}
}
// Check to see if the child replica was found.
if (childReplica == null)
{
throw new ArgumentException(
"The requested replica could not be found on the child GDS.");
}
// Synchronize the replica.
parentReplica.Name = parentReplica.Name + "_21";
IReplicationAgent replicationAgent = new ReplicationAgentClass();
replicationAgent.SynchronizeReplica(parentGDS, childGDS, parentReplica,
childReplica, conflictPolicy, syncDirection, columnLevel);
}
catch (COMException comExc)
{
throw new Exception(String.Format(
"Create replica errored: {0}, Error Code: {1}", comExc.Message,
comExc.ErrorCode), comExc);
}