Select to view content in your preferred language

Selection.Combine() throwing error in 3.3 but worked in 3.1

122
3
a month ago
dd_dev
by
Emerging Contributor

I have a block of code that creates a single selection object from the selections of each layer of a Group Layer. This worked fine in Pro 3.1 but now in the process of updating to 3.3 and it is failing with "ArcGIS.Core.ObjectDisconnectedException: 'This object has been previously disposed and cannot be manipulated.'" despite all objects having _disposed as false.

The original layer is a nested group layer, groups within groups. It fails when there are selections in both of the nested groups being combined.

private Selection GetSelectionFromGroupLayer(Layer inputLayer)
{
    Selection featureSelection = null;
    
    var groupLayer = (GroupLayer)inputLayer;

    IList<Layer> groupLayers = groupLayer.GetLayersAsFlattenedList().ToList();

    for (int i = 0; i < groupLayers.Count; i++)
    {
        var layer = groupLayers[i];
        if (layer is FeatureLayer)
        {
            var featureLayer = (FeatureLayer)layer;

            if (featureLayer.SelectionCount != 0)
            {
                if (featureSelection == null)
                {
                    featureSelection = featureLayer.GetSelection();
                }
                else
                {
                    Selection selection = featureLayer.GetSelection();

                    //fails here
                    featureSelection = featureSelection.Combine(selection, SetOperation.Intersection);
                }
            }

            featureLayer = null;
        }
        layer = null;
    }

    return featureSelection;
}

 Any suggestions?

0 Kudos
3 Replies
UmaHarano
Esri Regular Contributor

Hi @dd_dev 

I tried your code with a collection of nested feature layers from a file gdb and I did not see the crash. My map group layers look like this screenshot below. Can you please give me a information on your layers?

UmaHarano_0-1733353225305.png

 

0 Kudos
dd_dev
by
Emerging Contributor

dd_dev_0-1733398869062.png

All of the sublayers have the same data source, an Oracle Enterprise Geodatabase, just different definition queries. If all selected features are from the same sublayer, it's fine. Once there are features selected from multiple sublayers the error is thrown.

0 Kudos
UmaHarano
Esri Regular Contributor

Hi @dd_dev 

Would it be possible to reach out to Esri support for this one? I am not able to repro this. 

Thanks!

Uma

0 Kudos