How to create a replica in a connected environment

The following describes how to create a replica in a connected environment. A connected environment is where both replica geodatabases are connected on the same local area network (LAN) or wide area network (WAN) during replica creation.

Creating a replica

The following steps describe how to create a replica using ArcObjects:
  1. Connect to a geodatabase to host the parent replica and connect to a geodatabase to host the child replica. This requires initializing a geodataserver object for each connection. Geodataserver objects allow you to access a geodatabase on a LAN or a WAN through ArcGIS Server. To see how to initialize a geodataserver, refer to How to initialize a geodataserver object.
  2. Call the following procedure by pasting it into your application and passing in the following parameters:
One of the geodataservers that you initialized in Step 1. This is the geodataserver that hosts the parent replica.
The other geodataserver that you initialized in Step 1. This is the geodataserver that hosts the child replica.
The name of the replica that you want to create. This name cannot already be used in either replica geodatabase.
Specifies whether you want to create a two-way, one-way, or checkout replica.
The fully qualified name of the feature dataset to replicate (see the following note).
The replica geometry. Only features that intersect this geometry will be included in the replica. If you pass in null, then all features are replicated.
False means that the child does not already have the data. True means that the data already exists in both geodatabases and you want to register new replicas for this data. In typical cases, set this to false.
Although this example can only be used to replicate a feature dataset and its contents, the code can be altered to accept feature classes and tables.
// Creates a replica of all data in a feature dataset.
//accessType is an integer constant belonging to esriReplicaAccessType
static void createFeatureDatasetReplica(IGeoDataServer parentGDS, IGeoDataServer
    childGDS, String replicaName, int accessType, String featureDataset, IGeometry
    geometry, Boolean registerOnly)throws Exception{
    // Set and expand the replica datasets.
    IGPReplicaDataset gpReplicaDataset = new GPReplicaDataset();
    IGPReplicaDatasets gpReplicaDatasets = new GPReplicaDatasets();
    IGPReplicaDatasets gpReplicaDatasetsExpand = parentGDS.expandReplicaDatasets
    // Set the replica description.
    IGPReplicaDescription gpReplicaDesc = new GPReplicaDescription();
    gpReplicaDesc.setSingleGeneration((accessType ==
    // Set the replica options.
    IGPReplicaOptions replicaOptions = new GPReplicaOptions();
    // Create the replica.
    IReplicationAgent replicationAgent = new ReplicationAgent();
    replicationAgent.createReplica("", parentGDS, childGDS, replicaName,
        gpReplicaDesc, replicaOptions);

Development licensingDeployment licensing
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine: Geodatabase Update