AnsweredAssumed Answered

ArcPro 2.6 SDK Core Dump

Question asked by jeffboyton on Sep 1, 2020
Latest reply on Sep 1, 2020 by jeffboyton

In ArcPro 2.6 (and 2.6.1), this code snippet will core dump (it works in 2.5).  This is a much simplified version of a larger Add-In.  Is this a known issue?  Is there a way around this core dump (without altering the steps it requires)?

 

 

protected async override void OnClick()
{
   await QueuedTask.Run(() =>
   {
      string mapName = $"Map-Copy";

 

      //Get the map
      MapProjectItem mapProjectItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name == "Map");
      Map originalMap = mapProjectItem.GetMap();

 

      // Make a copy of the map
      Map newMap = MapFactory.Instance.CopyMap(originalMap);
      newMap.SetName(mapName);
      SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(6455);

 

      // Get the map frame in the layout
      LayoutProjectItem layoutProjectItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name == "Layout");
      Layout layout = layoutProjectItem.GetLayout();
      MapFrame frame = layout.Elements.FirstOrDefault(e => e.Name == "Map Frame") as MapFrame;

 

      //Set the map frame's map to the new copy
      frame.SetMap(newMap);

 

      // Change the spatial reference of the map
      newMap.SetSpatialReference(spatialReference);
   });
}

Outcomes