当前位置: 代码迷 >> C# >> ArcGIS Engine 二次开发 COM错误 HRESULT E_FAIL
  详细解决方案

ArcGIS Engine 二次开发 COM错误 HRESULT E_FAIL

热度:919   发布时间:2016-05-05 04:26:09.0
ArcGIS Engine 二次开发 COM异常 HRESULT E_FAIL
我的项目中使用Gp做intersect,调试没问题,打包后运行interset却出现HRESULT E_FAIL,但打包后使用GP做buffer却没问题。请问这个该如何解决呢,arcengine 10.0
下面是自裁剪intersect类:

public static IFeatureLayer GetIntersectFeature(string pLayerPath, string OutPath, string Option)
  {
    //ILayer pLayer;
Geoprocessor pGeoprocessor;
IGeoProcessorResult pGeoProcessorResult;
IGPUtilities pIGPUtilities;
IFeatureClass pFeatureClass;
IQueryFilter pQueryFilter;
    IFeatureLayer pFeatureLayer;

ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
intersect.in_features = pLayerPath;
intersect.out_feature_class = OutPath;
intersect.join_attributes = Option;
//pFeatureLayer = GetIGPProcessLayer(intersect as IGPProcess);
//return pFeatureLayer;

pGeoprocessor = new Geoprocessor();
ConnectGDBSQL pConnectGDBSQL = new ConnectGDBSQL();
IWorkspace pWorkspace = pConnectGDBSQL.ConnectGDB();

pGeoprocessor = new Geoprocessor();
pGeoprocessor.SetEnvironmentValue("workspace", pWorkspace.PathName);
pGeoprocessor.OverwriteOutput = true;
pGeoProcessorResult = pGeoprocessor.Execute(intersect, null) as IGeoProcessorResult;

pIGPUtilities = new GPUtilitiesClass();
pIGPUtilities.DecodeFeatureLayer(pGeoProcessorResult.GetOutput(0), out pFeatureClass, out pQueryFilter);
pFeatureLayer = new FeatureLayerClass();
pFeatureLayer.FeatureClass = pFeatureClass;
return pFeatureLayer;
  }

------解决思路----------------------
main中初始化licence时,只初始化最高级别的,另外 HRESULT E_FAIL 还可能是调用GP时参数上的错误,比如intersect时不要输入要素的物理路径(path),改成输入featureclass就不会出错,实际上输入path时开发调试时不会出错,打包后就会报HRESULT E_FAIL了。 我的环境:arcgis engine 10.0
  相关解决方案