I am trying to programmatically delete features in ArcGIS Pro SDK. And if they have associations, I am trying to delete the Associations and then delete the feature using the CreateChainedOperation method. But I get this error. What am I doing wrong?
Even the Delete Associations did not work when tried separately even without chaining
Any advice on this will be much appreciated.
Thank You

EditOperation deleteAssociationOperation = new();
deleteAssociationOperation.Callback(context => {
foreach (var assoc in assocs)
{
LogMessage($"Deleting Association: {assoc.Type}");
context.Invalidate(row);
AssociationDescription associationToDelete = new(assoc.Type, new RowHandle(assoc.FromElement, UN), new RowHandle(assoc.ToElement, UN));
deleteAssociationOperation.Delete(associationToDelete);
context.Invalidate(row);
}
}, enterpriseTable);
bool resultdelAssoc = await deleteAssociationOperation.ExecuteAsync();
if (!resultdelAssoc)
{
//MessageBox.Show(String.Format($"Could not delete features {row.GetGlobalID()}: {deleteRecordOperation.ErrorMessage}"));
LogMessage($"Could not delete Association {row.GetGlobalID()}: {deleteAssociationOperation.ErrorMessage}");
}
//deleteAssociationOperation.Execute();
else if (resultdelAssoc)
{
LogMessage("Deleting Associations Complete, Deleting Feature");
var chaineddeleteRecordOperation = deleteAssociationOperation.CreateChainedOperation();
// In order to update the Map and/or the attribute table. Has to be called before the delete.
chaineddeleteRecordOperation.Callback(context => {
context.Invalidate(row);
chaineddeleteRecordOperation.Delete(row);
context.Invalidate(row);
}, enterpriseTable);
bool resultDel = await chaineddeleteRecordOperation.ExecuteAsync();
if (!resultDel)
{
//MessageBox.Show(String.Format($"Could not delete features {row.GetGlobalID()}: {deleteRecordOperation.ErrorMessage}"));
LogMessage($"Could not delete features {row.GetGlobalID()}: {chaineddeleteRecordOperation.ErrorMessage}");
}
else if (resultDel)
{
LogMessage("Delete with Association Done");
}
}