ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Hosting Namespace / Host Class / Initialize Method / Initialize() Method
Example

In This Topic
    Initialize() Method
    In This Topic
    Call to initialize a Core Objects host process. The method must be called before constructing any objects from ArcGIS.CoreObjects library.
    Syntax
    Public Overloads Shared Sub Initialize() 
    public static void Initialize()
    Exceptions
    ExceptionDescription
    Thrown when initialization fails.
    Remarks
    The following conditions must all be met to successfully Initialize CoreHost:
    • The process must be 64 bit (i.e. Build Settings of x64
    • The process COM threading model must be single threaded apartment. [STAThread] must be present on the entry point of the application
    • ArcGIS Pro must be installed on the host machine
    • An ArcGIS Pro license must be available
    If Initialization fails, a System.Exception will be thrown. The message property will contain the reason

    Note: An ArcGIS Pro license can either be checked out (i.e. disconnected) or the 'sign me in automatically' check box is checked on the ArcGIS Pro login popup. To disconnect your license, run ArcGIS Pro, go to the Backstage, Licensing Tab.

    Example
    Initializing Core Host
    /// <summary>
      /// The main entry point for the application, responsible for initializing the ArcGIS Core Host.
      /// </summary>
      /// <remarks>This method must be marked with the <see cref="STAThreadAttribute"/> to ensure proper
      /// threading model. It initializes the ArcGIS Core Host, which is required before constructing any objects from the
      /// ArcGIS.Core namespace. If initialization fails, an error message is displayed and the application
      /// exits.</remarks>
      /// <param name="args">Command-line arguments passed to the application.</param>
      //[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;
        }
    
        //if we are here, ArcGIS.Core is successfully initialized
        Geodatabase gdb = new(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\SDK\GDB\MySampleData.gdb")));
        IReadOnlyList<TableDefinition> definitions = gdb.GetDefinitions<FeatureClassDefinition>();
    
        foreach (var fdsDef in definitions)
        {
          Console.WriteLine(TableString(fdsDef as TableDefinition));
        }
        Console.Read();
      }
    
      private static string TableString(TableDefinition table)
      {
        string alias = table.GetAliasName();
        string name = table.GetName();
        return string.Format("{0} ({1})", alias.Length > 0 ? alias : name, name);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also