Delete List of Rows Issue

292
1
01-26-2018 09:39 AM
MKa
by
Occasional Contributor III

When I delete a feature in my map, I have a list of child features that also need to be deleted.  When the parent is deleted, the child features of a different type also need to be deleted.  So I trigger this code to get this done. When a delete is triggered, i successfully get the list of Rows, then a call delete and I get this error on the .Execute() line

"Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt”

//Delete all of the lists created above
foreach (List<Row> individualRowList in ListsOfLists)
{
   if (!individualRowList.IsNullOrEmpty())
   {                            
      EditOperation deleteOperation = new EditOperation()
      {
         Name = string.Format("Deleted {0}", individualRowList),
         SelectModifiedFeatures = false,
         SelectNewFeatures = false
      };
      deleteOperation.Delete(individualRowList);
      deleteOperation.Execute();                            
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Tags (1)
0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

When removing items by looping through a list, you should loop through the rows in reverse.

0 Kudos