当前位置: 代码迷 >> 综合 >> 异常来自 HRESULT:0x80040258
  详细解决方案

异常来自 HRESULT:0x80040258

热度:34   发布时间:2023-11-17 07:15:10.0

C#AE开发对图层要素进行叠置分析时,老是报错,异常来自 HRESULT:0x80040258

代码如下:

public void Clip(AxMapControl m_map)
{try{//分析层ILayer pLayer = m_map.get_Layer(0);IFeatureLayer pInputFeatLayer = pLayer as IFeatureLayer;ITable pInputTable = pLayer as ITable;IFeatureClass pInputFeatClass = pInputFeatLayer.FeatureClass;//叠加表pLayer = m_map.get_Layer(1);ITable pOverlayTable = pLayer as ITable;//叠加分析表IFeatureClassName pFeatClassName = new FeatureClassNameClass();pFeatClassName.FeatureType = esriFeatureType.esriFTSimple;pFeatClassName.ShapeFieldName = "shape";pFeatClassName.ShapeType = pInputFeatClass.ShapeType;//工作空间名称IWorkspaceName pNewWSName = new WorkspaceNameClass();pNewWSName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";pNewWSName.PathName = @"D:\a";//数据集名称IDatasetName pDatasetName = pFeatClassName as IDatasetName;pDatasetName.Name = "intersectshp";pDatasetName.WorkspaceName = pNewWSName;//几何处理IBasicGeoprocessor pBGP = new BasicGeoprocessorClass();pBGP.SpatialReference = m_map.SpatialReference;IFeatureClass pOutputFeatClass = pBGP.Intersect(pInputTable, false, pOverlayTable, false, 0, pFeatClassName);//输出要素层设置IFeatureLayer pOutputFeatLayer = new FeatureLayerClass();pOutputFeatLayer.FeatureClass = pOutputFeatClass;pOutputFeatLayer.Name = pOutputFeatClass.AliasName;//添加图层m_map.AddLayer((ILayer)pOutputFeatLayer, 0);m_map.Update();}catch (Exception ex){LogHelper.Error(ex.Message);}
}

 调试每次到IFeatureClass pOutputFeatClass = pBGP.Intersect(pInputTable, false, pOverlayTable, false, 0, pFeatClassName);就报错,也不知道为什么报错,调了好几个地方,后面发现,是路径的问题,设置工作空间路径pNewWSName.PathName = @"D:\a";这一句,我原本的路径是不存在的,本以为它会新建,事实上,并没有.把这里改成已有文件夹路径,上面的几何处理语句就可以通过了。 
 

  相关解决方案