ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping.Offline Namespace / GenerateOfflineMap Class / GenerateReplicas Method
The map whose content will be replicated
The parameters used to configure the replication process
Example

In This Topic
    GenerateReplicas Method
    In This Topic
    Generate bi-directional replicas for all sync-enabled content in the map. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void GenerateReplicas( 
       Map map,
       GenerateReplicaParams replicaParams
    )
    Public Sub GenerateReplicas( _
       ByVal map As Map, _
       ByVal replicaParams As GenerateReplicaParams _
    ) 

    Parameters

    map
    The map whose content will be replicated
    replicaParams
    The parameters used to configure the replication process
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Map cannot be null
    Extent cannot be null or empty
    Map and extent spatial references must be equal
    Map has no sync-enabled content
    Remarks
    To generate a replica, the target feature service(s) must have bi-directional synchronization enabled. Feature service layers from a branch versioned feature service must be connected to the default version.
    At the conclusion of GenerateReplica, layers that were sourced on the target feature service(s), whose data was/were replicated, are re-sourced to point to the local copy of the geodatabase(s) created via the GenerateReplica process. The extent of data copied to the local geodatabase is controlled by the replicaParams.Extent property.
    Calling GenerateReplicas on a map with no sync-enabled content will throw a System.InvalidOperationException. See GetCanGenerateReplicas
    Example
    Generate Replicas for Sync-Enabled Content
    //namespace ArcGIS.Desktop.Mapping.Offline
    var extent = MapView.Active.Extent;
    var map = MapView.Active.Map;
    
    //await if needed...
    QueuedTask.Run(() =>
    {
      //Check map has sync-enabled content that can be taken offline
      var hasSyncEnabledContent = GenerateOfflineMap.Instance.GetCanGenerateReplicas(map);
      if (hasSyncEnabledContent)
      {
        //Generate Replicas and take the content offline
        //sync-enabled content gets copied local into a SQLite DB
        var gen_params = new GenerateReplicaParams()
        {
          Extent = extent, //SR of extent must match map SR
    
          //DestinationFolder can be left blank, if specified,
          //it must exist. Defaults to project offline maps location
          DestinationFolder = @"C:\Data\Offline"
        };
        //Sync-enabled layer content will be resourced to point to the
        //local replica content.
        GenerateOfflineMap.Instance.GenerateReplicas(map, gen_params);
    
      }
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also