Language: C#
Subject: CoreHost
Contributor: ArcGIS Pro SDK Team <[email protected]>
Organization: esri, http://www.esri.com
Date: 10/22/2024
ArcGIS Pro: 3.4
Visual Studio: 2022
.NET Target Framework: .Net 8
using ArcGIS.Core.Data;
//There must be a reference to ArcGIS.CoreHost.dll
using ArcGIS.Core.Hosting;
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;
}
//if we are here, ArcGIS.Core is successfully initialized
Geodatabase gdb = new Geodatabase(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);
}
}