Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for .NET

List geodatabase versions

This code sample is available for these platforms:
View Sample on GitHub

Connect to a service and list versions of the geodatabase.

Image of list geodatabase versions

Use case

As part of a multi-user editing scenario, you can check with the server to see how many versions of the geodatabase are outstanding before syncing.

How to use the sample

When the sample loads, a list of geodatabase versions and their properties will be displayed.

How it works

  1. Create a geoprocessing task referring to a GPServer with a ListVersions task.
  2. Use the task to create default parameters.
  3. Use the created parameters to create a job.
  4. Run the job to get a GeoprocessingResult.
  5. Get a list of geoprocessing features from the Versions output parameter of the results.
  6. Format the geodatabase versions for display.

Relevant API

  • GeoprocessingFeatures
  • GeoprocessingFeatures.Features
  • GeoprocessingJob
  • GeoprocessingJob.GetResultAsync
  • GeoprocessingParameters
  • GeoprocessingResult
  • GeoprocessingResult.Outputs
  • GeoprocessingTask
  • GeoprocessingTask.CreateDefaultParametersAsync
  • GeoprocessingTask.CreateJob

About the data

The sample uses a sample geoprocessing service hosted on ArcGIS Online.

Additional information

ArcGIS Server does not include a geoprocessing service for listing geodatabase versions. You must configure one using the steps defined in Geoprocessing service example: list, create, and delete geodatabase versions in the ArcMap documentation.


conflict resolution, data management, database, multi-user, sync, version

Sample Code

                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            <TextBlock Text="Current versions" Grid.Row="0" HorizontalAlignment="Center"/>
            <TextBox x:Name="theTextBox" Grid.Row="1" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Visible" />
        <Grid x:Name="busyOverlay" Visibility="Collapsed" Background="#8C000000" Grid.RowSpan="4">
            <Border HorizontalAlignment="Center" VerticalAlignment="Center" Padding="10" Background="#FFC6C4C4">
                    <ProgressBar IsIndeterminate="True" x:Name="progress" Height="20" />
                    <TextBlock Text="Getting versions from the geoprocessing task..." HorizontalAlignment="Left" Margin="5" Height="Auto" />
// Copyright 2016 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Tasks;
using Esri.ArcGISRuntime.Tasks.Geoprocessing;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Popups;
using Windows.UI.Xaml;

namespace ArcGISRuntime.UWP.Samples.ListGeodatabaseVersions
        name: "List geodatabase versions",
        category: "Geoprocessing",
        description: "Connect to a service and list versions of the geodatabase.",
        instructions: "When the sample loads, a list of geodatabase versions and their properties will be displayed.",
        tags: new[] { "conflict resolution", "data management", "database", "multi-user", "sync", "version" })]
    public sealed partial class ListGeodatabaseVersions
        // Url to used geoprocessing service
        private const string ListVersionsUrl =

        public ListGeodatabaseVersions()

            // Create the UI, setup the control references and execute initialization 

        private async void Initialize()
            // Set the UI to indicate that the geoprocessing is running

                // Get versions from a geodatabase
                IFeatureSet versionsFeatureSet = await GetGeodatabaseVersionsAsync();

                // Continue if we got a valid geoprocessing result
                if (versionsFeatureSet != null)
                    // Create a string builder to hold all of the information from the geoprocessing 
                    // task to display in the UI 
                    StringBuilder myStringBuilder = new StringBuilder();

                    // Loop through each Feature in the FeatureSet 
                    foreach (Feature version in versionsFeatureSet)
                        // Get the attributes (a dictionary of <key,value> pairs) from the Feature
                        IDictionary<string,object> myDictionary = version.Attributes;

                        // Loop through each attribute (a <key,value> pair)
                        foreach (KeyValuePair<string,object> attribute in myDictionary)
                            // Add the key and value strings to the string builder 
                            myStringBuilder.AppendLine(attribute.Key + ": " + attribute.Value);

                        // Add a blank line after each Feature (the listing of geodatabase versions)

                    // Display the result in the textbox
                    theTextBox.Text = myStringBuilder.ToString();
            catch (Exception e)
                await new MessageDialog(e.ToString(), "Error").ShowAsync();

            // Set the UI to indicate that the geoprocessing is not running

        private async Task<IFeatureSet> GetGeodatabaseVersionsAsync()
            // Results will be returned as a feature set
            IFeatureSet results = null;

            // Create new geoprocessing task 
            GeoprocessingTask listVersionsTask = await GeoprocessingTask.CreateAsync(new Uri(ListVersionsUrl));

            // Create default parameters that are passed to the geoprocessing task
            GeoprocessingParameters listVersionsParameters = await listVersionsTask.CreateDefaultParametersAsync();

            // Create job that handles the communication between the application and the geoprocessing task
            GeoprocessingJob listVersionsJob = listVersionsTask.CreateJob(listVersionsParameters);
                // Execute analysis and wait for the results
                GeoprocessingResult analysisResult = await listVersionsJob.GetResultAsync();

                // Get results from the outputs
                GeoprocessingFeatures listVersionsResults = (GeoprocessingFeatures)analysisResult.Outputs["Versions"];

                // Set results
                results = listVersionsResults.Features;
            catch (Exception ex)
                // Error handling if something goes wrong
                if (listVersionsJob.Status == JobStatus.Failed && listVersionsJob.Error != null)
                    MessageDialog message = new MessageDialog("Executing geoprocessing failed. " + listVersionsJob.Error.Message, "Geoprocessing error");
                    await message.ShowAsync();

                    MessageDialog message = new MessageDialog("An error occurred. " + ex.ToString(), "Sample error");
                    await message.ShowAsync();
                // Set the UI to indicate that the geoprocessing is not running

            return results;

        private void SetBusy(bool isBusy = true)
            if (isBusy)
                // Change UI to indicate that the geoprocessing is running
                busyOverlay.Visibility = Visibility.Visible;
                progress.IsIndeterminate = true;
                // Change UI to indicate that the geoprocessing is not running
                busyOverlay.Visibility = Visibility.Collapsed;
                progress.IsIndeterminate = false;