Calling GP-Tool "management.CreateReplica" from Add-In fails after Editing Non-versioned SDE-Layers

446
2
12-09-2020 06:54 AM
RalfSchmidt
New Contributor III

I narrowed down a strange problem with an Add-In I'm currently writing. Maybe, someone can help:

Summary

I created a use-case-specific UI for the users to checkout data for editing in the field. When the user hits my "Run" button I call the GP-Tool management.CreateReplica to actually create the checkout-FGDB. This works fine as long as the user did not edit – in the same ArcGIS Pro session – any non-versioned feature class or table from the same workspace as the layers to be checked out.

In Detail

Code for Calling the GP-Tool

 

 

 

private static async Task RunCheckoutGpTool(
    FeatureLayer checkoutAreasLayer, 
    IList<MapMember> layersAndStandAloneTables,
    string replicaName,
    Geodatabase targetFgdb, 
    CancelableProgressor cancelableProgressor)
{
    var parameters = Geoprocessing.MakeValueArray(
        layersAndStandAloneTables, // Layers and tables to be checked out
        "CHECK_OUT",               // Replication type
        targetFgdb.GetPath().LocalPath, // out_geodatabase
        replicaName,               // Replica Name
        "FULL",                    // access_type
        null,                      // initial_data_sender
        "USE_DEFAULTS",            // expand_feature_classes_and_tables
        "DO_NOT_REUSE",            // reuse_schema
        "GET_RELATED",             // get_related_data
        checkoutAreasLayer);       // Replication area
    IGPResult gpResult = await Geoprocessing.ExecuteToolAsync(
            "management.CreateReplica", parameters, null, cancelableProgressor);
    if (gpResult.IsFailed)
    {
        throw new Exception("Error executing Geoprocessing tool \"CreateReplica\":↵\n "
            + string.Join("↵\n ", gpResult.ErrorMessages));
    }
}

 

 

 

Note: checkoutAreasLayer is a polygon layer for which I assured that only a single feature is selected.

Some Observations

  1. Closing the project (by choosing "New" and "Start without a template" in Pro) and reopening the project heals the problem, i.e. my code runs without error and creates the Checkout datasets in the FGDB.
  2. The problem does not occur if only a versioned feature class or table from the same workspace was edited before the call to the GP tool.
  3. The problem does also not occur if a feature from an FGDB feature class was edited before.
  4. As a test, I edited data of a non-versioned feature class in an Add-In instead of through Pro's UI. If I use the EditOperation class for that it results in the same problem. If I instead edit a feature directly and call Store() then I don't have problem, i.e. I still can successfully call the GP tool.
  5. Using the "Create Replica" GP tool directly using the Pro UI never fails, i.e. calling the very same GP tool from the Add-In fails while calling it without custom code works.

Error message received

  • <msg code=\"782\" type=\"100\">ERROR 000782: Read only data or unversioned data cannot be checked out. Full versioning is required for all replica data.</msg>

  • <msg code=\"-2147467259\" type=\"100\">Failed to execute (CreateReplica).</msg>

This message makes no sense to me because all feature classes and tables to be checked out are versioned and writable. Moreover, the same GP tool called directly using Pro's UI works fine (as mentioned in previous section).

Environment

I tested the Add-In on two machine. The problem is reproducible on both: my development machine as well as in the test environment:

Development:

  • Windows 10 (Version 10.0.18363.1198)
  • ArcGIS Pro 2.6.3
  • SQL Server 2014 Express  Database (Version 2014.120.6118.4, i.e. current patch level)

Test:

  • Windows Server 2019 (VM using Microsoft Hyper-V Server 2019)
  • ArcGIS Pro 2.6.3
  • SQL Server 2019
0 Kudos
2 Replies
CherylCleghorn
Esri Contributor

Hi Ralf, 

Can you check the contents of the layersAndStandAloneTables list that is passed in for the failed case? Other than this we will need to troubleshoot this problem. Would you mind logging a case with Technical Support and providing the repro case?

Thanks

Cheryl

0 Kudos
RalfSchmidt
New Contributor III

Hi Cheryl,

Thanks for your answer.

I double-checked the layer list a number of times. Actually, to make sure the list is not the problem, I replaced it with hard-coded paths to the feature classes. Unfortunately, the behavior stayed the same.

I feared that I would need to contact Technical Support. Creating a repro case would essentially mean writing a new minimal AddIn that shows the problem.

Ralf

0 Kudos