ArcGIS Pro SDK (六)CoreHost

核心主机

环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0

1 初始化核心主机

csharp 复制代码
using ArcGIS.Core.Data;
//必须引用ArcGIS.CoreHost.dll
using ArcGIS.Core.Hosting;

class Program {
    //[STAThread] 必须出现在应用程序入口点上
    [STAThread]
    static void Main(string[] args) 
    {
        //必须在构造任何 ArcGIS.Core 对象之前调用 Host.Initialize 
        try {
            Host.Initialize();
        }
        catch (Exception e) {
            //错误(缺少安装、没有许可证、64位不匹配等)
            Console.WriteLine(string.Format("Initialization failed: {0}",e.Message));
            return;
        }

        //执行到这,ArcGIS.Core已经初始化成功
        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);
    }
}
相关推荐
火星papa9 小时前
C# 阻塞队列(BlockingCollection)
c#·queue·阻塞队列
WebGIS开发14 小时前
地理学硕士转行GIS开发经历分享
gis·webgis·地理学
OctShop大型商城源码14 小时前
.NET线上商城源码_C#商城源码_技术赋能下的电商新生态
开发语言·c#·.net·商城系统源码
hixiong12317 小时前
C#文件目录结构生成工具
开发语言·c#
滴滴答答哒19 小时前
# SqlSugar 差异日志功能实现
c#
顾温20 小时前
协程结束——实测
开发语言·unity·c#
非科班Java出身GISer21 小时前
ArcGIS Maps SDK for JavaScript 5.0 组件(Component)地图初始化示例
arcgis·arcgis js 组件化·arcgis js5.0初始化·arcgis js组件式·arcgis js组件初始化·component初始化·arcgis js 5.0
唐青枫1 天前
C#.NET YARP 详解:用 ASP.NET Core 打造高性能反向代理网关
c#·.net
asdzx671 天前
告别手工复制:用 C# 轻松合并多份 Word
c#·word
啦啦球晃晃1 天前
ArcGIS统计乡镇耕地面积
arcgis