AnsweredAssumed Answered

EditOperation.Execution caused by DB Corruption?

Question asked by daniel.huantes on Dec 5, 2018
Latest reply on Dec 5, 2018 by sean_jones-esristaff

I have a couple of routines that generate anywhere from 30-40 polygons with approximate 800+ points each.  I call each routine from two different ArcGIS Pro SDK Button Add-In Controls as part of my custom ArcGIS Pro Add-In.  After each routine I take the Polygons that were created add them to the map using the code below (sorry couldn't figure out how to format the coding correctly).  It was working for both buttons consistently until yesterday when only one button would work.  Meaning that I would click one button this routine would run and I'd see my polygons on the map and then I'd push the second button and the second time the routine would get stuck on the


bool l_created = l_createFeatures.Execute();


line of code (i.e. Execute() never returned).  After trying several different things I decided that maybe the problem was my database so I shutdown ArcGIS and I deleted the DefaultGeodatabase folder for my project.  I reran and it started working normally again.  Any thoughts on what happened and how I can prevent this from happening again?  See anything wrong with the code below?  Is there a problem with polygons with that many points?  My add-in is in beta release now but would like to know the root of the problem before final release.  Thank you.


// First obtain the FeatureLayer based on the name of the layer (l_featureClassName)
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
         var l_mapLayers = l_mapView.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
         foreach (FeatureLayer l_featureClassLayer in l_mapLayers)
               if (l_featureClassLayer.Name == l_featureClassName)
                     l_featureLayer = l_featureClassLayer;

//Second Set the Opacity for the Polygons so I can overlapping Polygons
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    //Create polygon outline.
    CIMStroke l_outline = SymbolFactory.Instance.ConstructStroke(

    //Create polygon fill with outline.
    CIMPolygonSymbol l_fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(
    ColorFactory.Instance.CreateRGBColor(0.0, 0.0, 0.0, 0.0),

    //Get layer's current renderer.
    CIMSimpleRenderer l_renderer = l_featureLayer.GetRenderer() as CIMSimpleRenderer;

    //Update current renderer's symbol.
    l_renderer.Symbol = l_fillWithOutline.MakeSymbolReference();

    //Update layer's renderer.

//Third Perform EditOperation to add polygons to layer
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>

      var l_createFeatures = new EditOperation();
      l_createFeatures.CancelMessage = "Operation Cancelled";
      l_createFeatures.ErrorMessage = "Error creating polygon";
      l_createFeatures.ShowProgressor = true;

      // l_arcGISPolygons is List<Polygon>
      for (int i = 0; i < l_arcGISResults.Count; i++)
            l_createFeatures.Name = $"Create Result Polygon #{i}";
            l_createFeatures.ProgressMessage = $"Adding Result Polygon #{i} to the Map.....";
            //Create a feature with a polygon.
            l_createFeatures.Create(l_featureLayer, l_arcGISResults[i]);

      //Execute the operation. Must be called within QueuedTask.Run.
      bool l_created = l_createFeatures.Execute();

// Finally Save Edits to Layer

await Project.Current.SaveEditsAsync();