Skip to content

ProSnippets CoreHost

UmaHarano edited this page Nov 12, 2025 · 23 revisions
Language:              C#  
Subject:               CoreHost  
Contributor:           ArcGIS Pro SDK Team <[email protected]>  
Organization:          Esri, http://www.esri.com  
Date:                  11/7/2025  
ArcGIS Pro:            3.6  
Visual Studio:         2022  

Initializing Core Host

The main entry point for the application, responsible for initializing the ArcGIS Core Host.

//[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);
}
  }

Home

ProSnippets: CoreHost

Clone this wiki locally