AnsweredAssumed Answered

Edit operation failed. - generic message in ArcGIS Pro SDK

Question asked by billm889 on Jun 27, 2018
Latest reply on Aug 8, 2018 by nchedzey-esristaff

I'm getting an intermittent error during an editing. This code is running as part of a Pro Add-in that I'm writing.

 

The error doesn't happen every time this function runs but if I repeatedly run this function it will eventually fail. Sometimes it will take 2 tries and other times it will take 20 ties. When running through Visual Studio it will error more frequently. When running as the compiled Add-in, it takes longer to error.


It fails at the insp.ApplyAsync() call with an error message with the heading "Update Feature Attributes" and the message text of "Edit operation failed.". This is some very generic message.

Edit operation failed.

 Another strange thing is that it doesn't hit my error handling for this initial message but after I close the initial message it will then drop to my error handling.


Part of the application's requirements is that I don't need to prompt the user to save edits.

 

I've also tried EditOperation combined with SaveEditsAsync() with the same error results.

 

The feature class is stored in a file geodatabase on my local drive.

 

ArcGIS Pro 2.0

 

Does anyone know how to prevent this error or code around it somehow?

 

internal static async Task<int> UpdateBoundarySubdivisionAttribute(string strSelectedAppNo, string strNewSubdivisions)
{
try
{
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(async () =>
{
// Find boundary layer.
var disLayer = ArcGIS.Desktop.Mapping.MapView.Active.Map.FindLayers(Settings.Get("pyp_boundary_layer_name")).FirstOrDefault() as BasicFeatureLayer;

 

// Search by application number attribute.
var queryFilter = new ArcGIS.Core.Data.QueryFilter();
queryFilter.WhereClause = "APPLICATION_NUMBER = '" + strSelectedAppNo + "'";
var rc = disLayer.Search(queryFilter);

 

// Create list of oids to update. There should only be one.
var oidSet = new List<long>();
while (rc.MoveNext()) { oidSet.Add(rc.Current.GetObjectID()); }

 

// Create Inspector.
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(disLayer, oidSet);
insp["SUBDNAME"] = strNewSubdivisions;

 

// Save edits with no undo. If you want the undo option then use EditOperation().
if (true != await insp.ApplyAsync()) // <-- point of error "Update Feature Attributes" "Edit operation failed."
{
   string ERR_PROC = " UpdateBoundarySubdivisionAttribute() ";
   System.Windows.MessageBox.Show("Error in ApplyAsync() ErrProcedure = " + ERR_PROC + " Unable to save edits the the feature class.", "Update Boundary Subdivision Error", MessageBoxButton.OK, MessageBoxImage.Error);
   return;
}
});

return await Task.FromResult(0);
}
catch (Exception ex)
{
string ERR_PROC = " UpdateBoundarySubdivisionAttribute() ";
System.Windows.MessageBox.Show("ErrProcedure = " + ERR_PROC + ex.Message, "Update Boundary Subdivision Error", MessageBoxButton.OK, MessageBoxImage.Error);
return await Task.FromResult(1); // Return error
}
}

Outcomes