调用GP工具报错问题
上周写代码调用了ESRI.ArcGIS.DataManagementTools下的两个GP:CreateEnterpriseGeodatabase和EnableEnterpriseGeodatabase,即创建企业级数据库和转换数据库为企业级数据库,但一直报错,报错内容如下:
Executing: EnableEnterpriseGeodatabase
Start Time: Mon Nov 15 14:19:41 2021
Failed to execute. Parameters are not valid.
ERROR 000824: The tool is not licensed.
Failed to execute (EnableEnterpriseGeodatabase).
Failed at Mon Nov 15 14:19:41 2021 (Elapsed Time: 0.00 seconds)
我利用arcgis自带的工具箱里的工具手动执行工具时,执行成功。其中执行参数和代码参数一模一样,工具没问题,但是代码执行就有问题。后来发现是授权问题,代码构造函数或者加载事件中,增加如下权限初始化代码,问题完美解决。
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.EngineOrDesktop, ESRI.ArcGIS.LicenseLevel.GeodatabaseUpdate);