I have a similar codeblock in my application as shown here in the Pro SDK Wiki snippets. I run this code when I need to access the map pane by name. It creates a new map pane everytime this code is run, is there a way to check and retrieve or select existing pane and if not able then to create it.
Also, the created map is not set as active view by default. I even tried to activate the view explicitly as shown.
IMapPane activePane = await ProApp.Panes.CreateMapPaneAsync(aoMaps.ElementAt(i).GetMap());
var currentPane = activePane as Pane;
if (currentPane != null)
Wolfgang Kaiser Thanks for sharing the sample. I have tried that and it didn't help. I have created a add-in to demonstrate the issue and attached herewith along with a sample project.
The sample add-in saves maps to a folder on computer as mapx files looping through all maps. The first map opens and saves perfectly fine. But when it tries to open second map and save it, the execution stops at this line of code
var activePane = await ProApp.Panes.CreateMapPaneAsync(item.GetMap());
At this point actually a map pane with the map is created by not initialized & activated.
The execution moves further only one when I select the second tab and the debugger point shown below hits. If I do not select the pane manually, it never completes execution.
Could you take a look and let me know how to make the pane initialized and activated automatically?
I duplicated your issue with my sample add-in, I can create one or two (at most) map panes before the [map pane creation] thread will hang. I am checking with the developers for any workarounds.
Besides the issue regarding the map pane initialization and activation, i think the you can implement your workflow, saving all maps in a common folder', because it is possible without first showing a map view pane. You can save the maps as follows:
protected override async void OnClick()
var pathToSaveFiles = @"c:\temp\maps";
var mapProjItems = Project.Current.GetItems<MapProjectItem>();
await QueuedTask.Run(() =>
foreach (var mapPro in mapProjItems)
catch (Exception ex)
I attached the sample project I used to duplicate your issued and also this code. If you want to run the sample, you need to download and use the 'C:\Data\Admin\AdminSample.aprx' project which comes with the community sample dataset here: https://github.com/Esri/arcgis-pro-sdk-community-samples/releases then click the 'CreateMaps' button followed by the 'SaveMaps' button which saves the map files to c:\temp\maps.
I am not able to duplicate any problems with activation of a mapview pane unless it is done in a tight loop with no user interaction with the mapview pane (other than just displaying and activating it). To activate a mapview pane you can lift the code from this sample: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/OpenMapViews and you can then do your custom processing on the active map view. Once you're done with your 'custom processing' and done saving your map, you can then repeat the same cycle for the next item. I have not seem any issues with this workflow, maybe if you can elaborate what type of processing you are doing i can try to duplicate the issue. There are plenty of issues that could be the cause of a hang but the pane activation for this type of workflow is not the reason.