Skip to content

ProConcepts CoreHost

UmaHarano edited this page Nov 6, 2024 · 22 revisions

This topic provides a brief introduction to building stand-alone apps with the ArcGIS Pro ArcGIS.CoreHost and ArcGIS.Core assemblies.

ArcGIS.CoreHost.dll
ArcGIS.Core.dll

Language:      C#
Subject:       CoreHost
Contributor:   ArcGIS Pro SDK Team <arcgisprosdk@esri.com>
Organization:  Esri, http://www.esri.com
Date:          10/06/2024
ArcGIS Pro:    3.4
Visual Studio: 2022

In this topic

ArcGIS.Core.dll

ArcGIS.Core.dll provides 64-bit access to the Geodatabase and Geometry classes used by ArcGIS Pro. This assembly can be referenced in either an ArcGIS Pro Add-in or embedded in a console or WPF app. Unlike in an add-in, when ArcGIS.Core.dll is used in a console app (or WPF app), you must first initialize the underlying environment by calling the static Host.Initialize method on the ArcGIS.Core.Hosting.Host class located in the ArcGIS.CoreHost assembly. After initialization, any of the ArcGIS.Core.dll types can be constructed and accessed. (Note: Attempting to access any of the ArcGIS Pro UI elements or types in other assemblies in an ArcEngine-like fashion will crash your program).

This topic walks you through the procedure for configuring your app to run ArcGIS.Core external to the ArcGIS Pro Add-in framework.

Prerequisites

  1. ArcGIS Pro must be installed on either the developer machine or the host machine on which your program will be run.
  2. You must configure your ArcGIS Pro license settings in one of the following ways:
    • Single Use License
    • Concurrent Use License
    • Named User License --and--
      • Either:
      • Check the Authorize ArcGIS Pro to work offline check box on the Backstage tab --or--
      • Check the Sign me in automatically check box on the ArcGIS Sign In pop-up.

Note: If you are using Single Use or Concurrent Use license mechanisms, you can configure Pro's licensing without a user interface (UI) by running the ArcGIS Pro setup program using Windows Installer command line parameters. Refer to the Install ArcGIS Pro silently documentation to configure Single Use or Concurrent use licenses for an un-attended option.

Backstage Authorize ArcGIS Pro to work offline

Licensing options dialog

ArcGIS Sign In Sign me in automatically (for Named User License)

Sign me in automatically

Host.Initialize

In Visual Studio, create a new console application. Add references to the following two DLLs, both located in the ArcGIS Pro bin folder:

  • ArcGIS.CoreHost.dll
  • ArcGIS.Core.dll

On the Build properties dialog box of your project, change the Platform Target combo box to be x64 (by default it will be Any CPU).

Visual Studio Build Settings

In your code, add the [STAThread] attribute above the console's static Main(string[] args) method. The presence of the STAThread attribute forces the application's primary thread to initialize as an STA thread the first time the application does any interoperability work with COM (for example, via the first call to a type in ArcGIS.Core.dll).

STAThread

Initialize the Host class before accessing any types within the ArcGIS.Core assembly. To initialize the Host class, call its static Initialize method:

class Program {
        //[STAThread] must be present on the Application entry point
        [STAThread]
        static void Main(string[] args) {

            //Call Host.Initialize before constructing any objects from ArcGIS.Core
            try {
                Host.Initialize();
            }
            catch (Exception e) {
                // Error (missing installation, no license, 64 bit mismatch, etc.)
                Console.WriteLine(string.Format("Initialization failed: {0}",e.Message));
                return;
            }

There is no return value. If initialization is successful, program execution will continue, and ArcGIS.Core functionality can be accessed. If initialization fails, a System.Exception will be thrown on the Initialize call.

Note: You do not need to call a shutdown method to unload the ArcGIS.Core assembly (similar to IAoInitialize.Shutdown in ArcObjects).

Initialize sequence

Host.Initialize checks:

  1. Is the Program 64 bit?
  2. Is the process COM threading model single-threaded apartment (STA)?
  3. Is ArcGIS Pro installed?
  4. Can ArcGIS Pro licensing be initialized? (See prerequisites)

Any failure in the initialization sequence will result in a System.Exception. Check the returned message in the System.Exception from Host.Initialize, and take the appropriate corrective action.

Automating Pro

Automating ArcGIS Pro Mapping is supported in arcpy.mp. You can find more information in What is ArcPy?.

Editing Geodatabase Datasets

In order to edit datasets in a Geodatabase while running ArcGIS.Core external to the ArcGIS Pro Add-in framework, the ArcGIS.Core.Data namespace provides the Geodatabase.ApplyEdits method. See Editing in stand-alone mode for more details.

Deployment

The prerequisites for deploying an executable taking advantage of ArcGIS.CoreHost.dll and ArcGIS.Core.dll are as follows:

  1. ArcGIS Pro must be installed on the host machine.
  2. The licensing prerequisites must be met when the program is run.

Developing with ArcGIS Pro

    Migration


Framework

    Add-ins

    Configurations

    Customization

    Styling


Arcade


Content


CoreHost


DataReviewer


Editing


Geodatabase

    3D Analyst Data

    Plugin Datasources

    Topology

    Linear Referencing

    Object Model Diagram


Geometry

    Relational Operations


Geoprocessing


Knowledge Graph


Layouts

    Reports


Map Authoring

    3D Analyst

    CIM

    Graphics

    Scene

    Stream

    Voxel


Map Exploration

    Map Tools


Networks

    Network Diagrams


Parcel Fabric


Raster


Sharing


Tasks


Workflow Manager Classic


Workflow Manager


Reference

Clone this wiki locally