Skip To Content ArcGIS for Developers Sign In Dashboard

Local Server

Local Server, an optional component of ArcGIS Runtime SDK for .NET, is primarily for executing offline geoprocessing tasks in your ArcGIS Runtime apps. These tasks work in the same way as geoprocessing tasks published from ArcGIS Online or ArcGIS Enterprise. Running a geoprocessing task on Local Server requires an ArcGIS Pro or ArcMap geoprocessing package (.gpkx or .gpk file). These packages are authored in ArcGIS Desktop either using Model Builder or by writing a Python script.

Local Server also allows developers to consume map image layers or feature layers from content in an ArcGIS Pro or ArcMap map package (.mpkx or .mpk file). These packages are authored and created using ArcGIS Desktop. This capability has been included to support workflows in earlier versions of ArcGIS Runtime. If you're starting a new project and require offline data, use sync-enabled geodatabases, which are generated from feature services.

Local Server can be downloaded for Windows (32- and 64-bit) .

To develop with Local Server you must install the ArcGIS Runtime Local Server SDK and add the Esri.ArcGISRuntime.LocalServices NuGet package to your WPF application project. To deploy your app with Local Server capabilities you must configure the ArcGIS Runtime Local Server manifest file which is automatically generated in your WPF application project folder.

Installing the Local Server SDK

Install Local Server on Windows

  1. Ensure that your development machine meets the system requirements for ArcGIS Runtime Local Server SDK .NET. Development and deployment machines must also have the following packages installed:
    • Microsoft Visual C++ Redistributable for Visual Studio 2017
    • Development and deployment on Windows 8.1, Windows Server 2012, Windows Server 2012 R2, or Windows 7 SP1 also requires installation of the Windows 10 Universal C Runtime via the following Windows Updates or Update Packages:
      • Update for Windows 8.1 (KB2999226)
      • Update for Windows 8.1 for x64-based Systems (KB2999226)
      • Update for Windows Server 2012 R2 (KB2999226)
      • Update for Windows Server 2012 (KB2999226)
      • Update for Windows 7 (KB2999226)
      • Update for Windows 7 for x64-based Systems (KB2999226)
  2. Download Local Server from the Downloads page. You'll need to log in with an ArcGIS developer account. Sign up for a free account if you haven't already. Save the file to a location on your development machine.
  3. Extract the file you downloaded, and then double-click the Setup.exe file to start the installation wizard.
  4. Follow the instructions. In the Destination Folder dialog, you can change the default installation directory by clicking the Change button, then navigating to the desired folder. Make sure you have write permissions to this folder on your development machine. Ensure no other users are using the folder.
  5. On the last panel of the wizard, click Finish. The ArcGIS Runtime Local Server is now installed at the installation folder you chose in the previous step.

Installing database client software for enterprise geodatabase connections

If any of your Local Server packages make use of enterprise geodatabase connections (SDE), then you may need to install the client software for the database you are connecting to. The section on Database connections gives details on the configuration of database client software.

Install and deploy Local Server

When developing an ArcGIS Runtime app, you can use a lightweight client API to work with classes in Local Server. The Local Server components themselves are installed separately with ArcGIS Runtime Local Server SDK. To limit the file size of your deployed app, you can limit the Local Server components to contain only those used in your app.

Local Server Runtime SDK and client API

To develop with Local Server, you need to add the Esri.ArcGISRuntime.LocalServices NuGet package to your project.

LocalServices NuGet package

This package provides the Local Server client API for you to program against in your WPF application project, but does not install the underlying Local Server SDK. The first time you build your project with the client API package included, you will receive a build error like the following if the underlying Local Server SDK is not installed on your machine.

Visual Studio build error

Download the setup for the Local Server SDK. Once the Local Server SDK is installed on your development machine, Visual Studio will be able to locate the Local Server components and you can successfully build projects that include the client API.

Deploying Local Server

The first time you build a project that uses Local Server, a deployment manifest file will be created in your project directory (ArcGISLocalServer_100.x.AGSDeployment).

Note:

The deployment file is created in your project directory, but is not added to your Visual Studio project. To see it listed in the Solution Explorer window, you will need to choose to Show All Files.

This is an XML-formatted text file that defines the components (listed as Package elements) of Local Server to deploy for your app. The two top-level Package elements in the file provide the ability to read map and geoprocessing packages produced from ArcGIS Pro or ArcMap respectively. Under each of those parent elements are child Package elements that provide specific functionality for that data format, such as geoprocessing or Python scripting support. By default, only the ArcMap Local Server component is included. To include additional capabilities (either within the ArcMap Local Server or to add ArcGIS Pro support), you need to edit this file manually. Only those Local Server packages with an enabled value of true are included in the deployment. The following configuration setting adds support for ArcGIS Pro map and geoprocessing packages (only available for 64-bit deployments).
<!--This local server has support for ArcGIS Pro mpkx and gpkx packages. It is 64 bit only-->
<Package id="Pro" name="ArcGIS Pro Compatible Server" enabled="true">
Note:

If you choose to include the ArcGIS Pro compatible Local Server with your deployment, but are not building for 64-bit, you will receive a build error. To include ArcGIS Pro support, your project must be set to build for x64 or Any CPU with the prefer 32-bit option unchecked.

When you build your project, the components you have enabled in ArcGISLocalServer_100.x.AGSDeployment will be included in the output for the platform(s) you're building. If building for 64-bit, for example, the requested Local Server components will be copied to your project's output folder under LocalServer100.x\64\.. If building for Any CPU (and Prefer 32-bit is unchecked in your project build properties), you will have a 32 and a 64 folder under the LocalServer100.x parent folder.
Note:

Previous versions of ArcGIS Runtime SDK for .NET provide a Visual Studio menu to add an ArcGIS Runtime deployment manifest to the project as well as a UI for updating this file. If you have a previous version installed, you will receive an error when trying to add the older deployment manifest file to a project that uses the current version ("unsupported SDK version").

Apart from installing the Local Server SDK and ensuring you have edited the deployment file to include the components you need, there are no additional steps for deploying Local Server capabilities for your ArcGIS Runtime SDK for .NET app.

Start a Local Server instance

You must start a Local Server instance if you want your app to use any services on the Local Server. Only one instance of the Local Server can be running at any time.

  1. LocalServer is a singleton object, which means there is always just one instance of the LocalServer class available in your code. You do not need to create an instance of LocalServer, you simply access it with the Instance static property. The following code stores the LocalServer instance in a private field, wires a listener for the StatusChanged event, then starts the server.
    private Esri.ArcGISRuntime.LocalServices.LocalServer _localServer;
    
    private async void StartLocalServer()
    {
        // Get the singleton LocalServer object using the static Instance property.
        _localServer = Esri.ArcGISRuntime.LocalServices.LocalServer.Instance;
    
        // Handle the StatusChanged event to react when the server is started.
        _localServer.StatusChanged += ServerStatusChanged;
    
        // Start the Local Server instance.
        await _localServer.StartAsync();
    }
    
    private void ServerStatusChanged(object sender, StatusChangedEventArgs e)
    {
        // Check if the server started successfully.
        if (e.Status == LocalServerStatus.Started)
        {
            // Start specific local services here ...
        }
    }
  2. Once the Local Server has started, you can start services (such as geoprocessing services, for example) as described in the following sections.
  3. When an application is closed down, the Local Server should also be shut down by calling StopAsync.
    _localServer.StopAsync();
    // ... or ...
    // Esri.ArcGISRuntime.LocalServices.LocalServer.Instance.StopAsync();

Run geoprocessing services

Geoprocessing services can be used from Local Server with a geoprocessing package file (.gpkx or .gpk file). The geoprocessing packages are authored and published using ArcGIS Pro or ArcMap. When preparing a geoprocessing package with ArcGIS Pro, use the Package Result tool and be sure to check the Support ArcGIS Runtime box in the Parameters pane. If this box is not checked, the .gpkx file will not run as a Local Server service. For more information about geoprocessing, see Run a geoprocessing task.

A local geoprocessing service can be started provided that the Local Server is started. The following code shows how to start the service and set up a task to use the "Message in a bottle" sample geoprocessing package.

// Create a local GP service from a geoprocessing package on disk.
LocalGeoprocessingService localServiceGP = new LocalGeoprocessingService(@"F:\Data\message-in-a-bottle.gpkx");

// Start the local service.
await localServiceGP.StartAsync();

// If the service was not started successfully, report status and return.
if (localServiceGP.Status != LocalServerStatus.Started)
{
    MessageBox.Show("Local Server could not be started.", "Error");
    return;
}

// If the service is started, get the URL for the specific geoprocessing tool.
string gpSvcUrl = localServiceGP.Url.AbsoluteUri + "/MessageInABottle";

// Create the geoprocessing task with the URL.
GeoprocessingTask gpMsgInBottleTask = await GeoprocessingTask.CreateAsync(new Uri(gpSvcUrl));

// Create parameters, run the task, process results, etc.
// ...

When running geoprocessing tools in the context of local server, the recommended approach for output data is to write the output data to a specific location on the local file system determined by the application or by the script/model and access the data directly from that location instead of returning a parameter of type GeoprocessingDataFile and using its FetchFileAsync function to return the content via http, which is usually less efficient. To do this, take one of the following approaches:

  • Expose an input parameter in the script/model representing the path where the output should be written to the local file system. The application code would then calculate/derive the location and pass that into the tool input parameters.

  • Calculate/derive a path within the script/model where the output will be written to the local file system and return that as a parameter in the script/model. The application code would then retrieve the location form the tool output parameters.

To learn how to use ArcGIS Pro to create a geoprocessing result that can be shared as a geoprocessing package, try the DevLab.

Run map image layer services

Map services can be consumed from Local Server using a map package file. Provided that the Local Server is started, you can start a service. Once the service is started, the URL is obtained and used to add an ArcGISMapImageLayer to your map.

// Create a local map service from a map package on disk.
LocalMapService mapService = new LocalMapService(@"F:\Data\PointsofInterest.mpk");

// Start the local service.
await mapService.StartAsync();

// If the service was not started successfully, report status and return.
if (mapService.Status != LocalServerStatus.Started)
{
    MessageBox.Show("Local Server could not be started.", "Error");
    return;
}

// If the service is started, get the service URL.
Uri mapServiceUrl = mapService.Url;

// Create a new ArcGISMapImageLayer.
ArcGISMapImageLayer localServiceLayer = new ArcGISMapImageLayer(mapServiceUrl)
{
    // Set layer opacity to semi-transparent.
    Opacity = 0.5
};

// Add the layer to the map.
MyMapView.Map.OperationalLayers.Add(localServiceLayer);
Example of ArcGISMapImageLayer from a local map service.

Run feature services

Feature services can also be consumed from a Local Server instance. As with map services, these services use a map package file (.mpkx or .mpk) that has been authored and published from ArcGIS Desktop.

The code below shows how to start the service, obtain the URL, and use this to add a feature layer to the map.

// Create a local feature service from a map package on disk
LocalFeatureService featureService = new LocalFeatureService(@"F:\Data\PointsofInterest.mpk");

// Start the local service.
await featureService.StartAsync();

// If the service was not started successfully, report status and return.
if (featureService.Status != LocalServerStatus.Started)
{
    MessageBox.Show("Local Server could not be started.", "Error");
    return;
}

// If the service is started, get the service URL.
string featureServiceUrl = featureService.Url.AbsoluteUri;

// Create a new service feature table from the dataset with index 0.
ServiceFeatureTable localServiceTable = new ServiceFeatureTable(new Uri(featureServiceUrl + "/0"));

// Create a new feature layer to display the features in the table.
FeatureLayer featureLyr = new FeatureLayer(localServiceTable);

// Add the layer to the map.
MyMapView.Map.OperationalLayers.Add(featureLyr);

Manage local services

When using the Local Server you are effectively a server administrator. You choose which services to create, determine the server-side properties of the services, and manage the service life cycles. Unlike online services, where all the service parameters are predefined by the service publisher, you must specify the local service settings via the API based on how your app needs to interact with the local service.

The API provides a class to represent each service type, allowing you to set the source content, such as a map or geoprocessing package; set the service properties; and manage the service life cycle by starting and stopping the service as required by your workflow. Services must be set up with the appropriate package type to begin with, and then they can be started. Once the service has started, you can obtain its URL and use it in other API classes such as layers and tasks. For example, you can use the URL of a local map service to create an ArcGISMapImageLayer. If your app no longer requires the service, you can choose to stop specific services via the API, which will allow the system to reclaim any memory used by those services.

When creating local geoprocessing services to run geoprocessing tools and models, you must choose whether the service will run synchronously (Execute), asynchronously (SubmitJob), or asynchronously with a dedicated local map service instance to draw the result (SubmitJobWithMapServerResult). Once the service is running, it is not possible to change the execution type. Note that although the terms synchronous and asynchronous are used, these actually refer to the internal infrastructure the Local Server uses to manage these services, and from an API perspective the execution is always asychronous. The decision is typically based on the type of analysis or processing that will be performed and the result type. If the tool will take less than a few seconds to run, the Execute type is recommended. If the tool will take longer and you would like to be able to determine the progress via the API, and perhaps report this to the user, the SubmitJob type is recommended. In some cases, your analysis might return such a large number of features that it would be inadvisable to obtain the features directly and display them as graphics, and better to instead render them in a result map service. Additionally, raster datasets and raster layers are not directly supported as output data types and instead must be rendered in a result map service. In both these latter cases, you should choose the SubmitJobWithMapServerResult execution type.

The following code shows how to start a local geoprocessing service programmatically.

//LocalGeoprocessingServices are started from Geoprocessing packages (.Gpk files). 
//Settings such as ServiceType and max records need to be set on the service before it starts. 

LocalGeoprocessingService gpService = new LocalGeoprocessingService(GPK_PATH, GeoprocessingServiceType.Execute);

//Local services must be started programmatically using the StartAsync method
   
await gpService.StartAsync();

Once started, the Url property of the LocalGeoprocessingService can be used as the ServiceUri property of a Geoprocessing task.

_gpTask = new Geoprocessor(new Uri(gpService.UrlGeoprocessingService));

Local Server Utility

Just as with full server and online services, there are times when you would like access to additional information on services running in the Local Server and also information on the interaction between the API and the service. The ArcGIS Runtime API and Local Server provide facilities for this. It is important here to make a distinction between the Local Server instance within the SDK installation the API uses by default versus a Local Server deployment. The instance included with the SDK installation includes all the components and has several features enabled that can help you debug local services, whereas a deployed instance of the Local Server has debugging options disabled by default to minimize the disk footprint and to ensure the security of the Local Server.

Debug settings are administered via the Local Server Utility application. This is automatically included in the SDK instance of the Local Server but must be explicitly included in a deployment when specifying options in the deployment builder. The Local Server Utility provides you with the ability to control how apps work with the Local Server. You can specify logging to help debug ArcGIS Runtime issues, enable HTTP traffic to be viewed in a network monitoring tool, select port range to avoid conflicts, delete temporary files, and provide error reports.

The Local Server Utility can be found in the Local Server installation folder. For example: C:\Program Files (x86)\ArcGIS SDKs\LocalServer100.x\64\bin\LocalServerUtility.exe

ArcGIS Runtime Local Server utility application window.

ArcGIS Runtime REST services directory

Local Server provides a services directory like the ArcGIS Services Directory available with online services. This provides a user-friendly HTML view of the service metadata JSON. You can use the HTML service definition and task pages to discover how to code against your services.

The services directory can be accessed via the Local Server URL and can be viewed in a browser to explore service parameters. The Local Server instance in the SDK installation by default includes the HTML server pages, while a deployment of the Local Server does not. This setting is controlled via the Local Server Utility (Generate HTML Server Pages checkbox). Another setting in the Local Server Utility that determines how you work with the services directory is the Add Random Prefix to Server URLs option. If disabled, the Local Server will have a predictable URL each time it is started by your application, making it easier for you to work with the services directory between debugging sessions. Although local services cannot be accessed outside the local machine, the random prefix option was added to provide additional security from applications running on the local machine.

ArcGIS Runtime REST Services Directory.

Supported raster formats

Local Server supports the raster dataset file formats supported by ArcGIS Desktop.