ArcObject 10.2调用FeatureToLine出错

ArcObject 10.2调用FeatureToLine出错,错误信息为:对 COM 组件的调用返回了错误 HRESULT E_FAIL。以下是我写的调用函数.其中inputFile是本地shp文件,outputFile为输出路径设置为shp文件.请问是哪里出错了呢?

public static bool FeatureToPolyline(string inputFile, string outputFile)
{
bool result = true;
var outfileName = Path.GetFileNameWithoutExtension(inputFile);
outputFile = string.Format(@"C:\Users\Peter\Documents\ArcGIS\Default.gdb\{0}", outfileName);
var featureToLine = new FeatureToLine();
featureToLine.in_features = inputFile;
featureToLine.out_feature_class = outputFile;
featureToLine.cluster_tolerance = 0.0001;
//featureToLine.attributes = false;
var geoProcessor = new Geoprocessor();
//初始化工作空间
geoProcessor.SetEnvironmentValue("workspace", @"C:\Users\Peter\Documents\ArcGIS\Default.gdb");
geoProcessor.OverwriteOutput = true;
try
{
geoProcessor.Execute(featureToLine, null);
}
catch (Exception ex)
{
result = false;
}
return result;
}
上网查了许多资料说是权限问题,但是我已经设置了高级.代码如下,同时通过armap 10.2的arctool手动执行正常工作.

private void InitializeEngineLicense()
{
if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.EngineOrDesktop, ESRI.ArcGIS.LicenseLevel.GeodatabaseUpdate);
AoInitialize aoi = new AoInitializeClass();
//Additional license choices can be included here.
esriLicenseProductCode productCode =esriLicenseProductCode.esriLicenseProductCodeAdvanced;

if (aoi.IsProductCodeAvailable(productCode) ==
esriLicenseStatus.esriLicenseAvailable)
{
var licenseStatus=aoi.Initialize(productCode);
if (licenseStatus == esriLicenseStatus.esriLicenseNotInitialized)
{
MessageBox.Show("没有esriLicenseProductCodeAdvanced许可!");
}
aoi.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst);
aoi.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeRuntimeAdvanced);
aoi.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);
aoi.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeDataInteroperability);
}
}
已邀请:

Cmystery - 菜鸟一枚

赞同来自:

            catch (Exception ex)
            {
                // Print a generic exception message.
                Console.WriteLine(ex.Message);
                // Print geoprocessing execution error messages.
                Console.WriteLine(gp.GetMessages(ref sev));
            }
获取详细报错情况

Leo_Terry

赞同来自:

ESRI.ArcGIS.ProductCode.EngineOrDesktop
换成ESRI.ArcGIS.ProductCode.Desktop试试

要回复问题请先登录注册