Arcgis Engine The supplied command does not exist in command pool?

private IGeometry GetMergeGeometry()
{
IFeatureLayer pFeatureLayer = mainMapControl1.get_Layer(1) as IFeatureLayer;
IGeometryBag pGeometryBag = new GeometryBag() as IGeometryBag;
pGeometryBag.SpatialReference = GetSpatialReference();
IGeometryCollection pGeometryCollection = pGeometryBag as IGeometryCollection;

// 属性过滤
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.AddField("Shape");

// 要素游标
IFeatureCursor pFeatureCursor = pFeatureLayer.FeatureClass.Search(pQueryFilter, true);
IFeature pFeature = pFeatureCursor.NextFeature();
if (pFeature == null)
{
return null;
}

// 遍历游标
object missing = Type.Missing;
while (pFeature != null)
{
pGeometryCollection.AddGeometry(pFeature.ShapeCopy, ref missing, ref missing);
pFeature = pFeatureCursor.NextFeature();
}
Marshal.ReleaseComObject(pFeatureCursor);

// 合并要素
ITopologicalOperator2 pTopologicalOperator = null;
if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
{
pTopologicalOperator = new Multipoint() as ITopologicalOperator2;
pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);
}
else if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
pTopologicalOperator = new Polyline() as ITopologicalOperator2;
pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);
}
else
{
pTopologicalOperator = new Polygon() as ITopologicalOperator2;
//问题显示:使用的工具并未在工具池中找到。
pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);
}
return pTopologicalOperator as IGeometry;
}
1、为了解决 TopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);“未指定的错误(Exception from hresult:0x80004005(E_FAIL))”的问题,用管理员身份打开VS,问题变为The supplied command does not exist in command pool。
 
已邀请:

朱新颖

赞同来自:

pFeatureLayer.FeatureClass.Search(pQueryFilter, true);第二个参数改为false试试

要回复问题请先登录注册