ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Hosting Namespace / Host Class / Initialize Method / Initialize(LicenseProductCode) Method
the license product code.
Example

In This Topic
    Initialize(LicenseProductCode) 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 static void Initialize( 
       Host.LicenseProductCode licenseProdCode
    )
    Public Overloads Shared Sub Initialize( _
       ByVal licenseProdCode As Host.LicenseProductCode _
    ) 

    Parameters

    licenseProdCode
    the license product code.
    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 should be single threaded apartment. [STAThread] should 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
    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);
        }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also